-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various performance improvements and cleanup
- Loading branch information
Showing
12 changed files
with
342 additions
and
228 deletions.
There are no files selected for viewing
301 changes: 149 additions & 152 deletions
301
AssetRelationsViewer/Editor/AssetRelationsViewerWindow.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using Com.Innogames.Core.Frontend.NodeDependencyLookup; | ||
|
||
namespace Com.Innogames.Core.Frontend.AssetRelationsViewer | ||
{ | ||
/// <summary> | ||
/// Thread to calculate the hierarchy size of nodes in the background | ||
/// </summary> | ||
public class NodeSizeThread | ||
{ | ||
private readonly Stack<VisualizationNodeData> _stack = new Stack<VisualizationNodeData>(); | ||
private readonly HashSet<string> _traversedNodes = new HashSet<string>(); | ||
private Thread _thread; | ||
private NodeDependencyLookupContext _context; | ||
|
||
public NodeSizeThread(NodeDependencyLookupContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public void Start() | ||
{ | ||
_thread = new Thread(ThreadProc); | ||
_thread.Name = "HierarchySizeThread"; | ||
_thread.Start(); | ||
} | ||
|
||
public void Kill() | ||
{ | ||
_thread?.Abort(); | ||
_stack.Clear(); | ||
} | ||
|
||
public void EnqueueNodeData(VisualizationNodeData nodeData) | ||
{ | ||
_stack.Push(nodeData); | ||
} | ||
|
||
private void ThreadProc() | ||
{ | ||
HashSet<Node> flattedHierarchy = new HashSet<Node>(); | ||
|
||
while(true) | ||
{ | ||
while (_stack.Count > 0) | ||
{ | ||
VisualizationNodeData visualizationNodeData = _stack.Pop(); | ||
visualizationNodeData.HierarchySize = NodeDependencyLookupUtility.GetTreeSize(visualizationNodeData.Node, _context, flattedHierarchy); | ||
} | ||
|
||
Thread.Sleep(5); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.