public void Search(bool masterThread) { while (searchCollection.Count != 0) { var currenNodeModel = searchCollection.Peek(); var childNode = this.nodeProcessor.GenerateNextChild(currenNodeModel); if (childNode != null && !childNode.Equals(NodeProcessor.VidNode)) { PushNode(childNode); } // Remove the node if it doesn't have anymore children if (!this.nodeProcessor.HasMoreChildren(currenNodeModel)) { searchCollection.Pop(); } else { if (masterThread) { threadSearch(currenNodeModel); } } } if (masterThread) { this.threadPool.WaitAll(); } }
public void Search(bool masterThread) { while (searchCollection.Count != 0) { var currentNodeModel = searchCollection.Pop(); while (this.nodeProcessor.HasMoreChildren(currentNodeModel)) { var childNode = this.nodeProcessor.GenerateNextChild(currentNodeModel); if (childNode != null && !childNode.Equals(NodeProcessor.VidNode)) { if (prune.IsPrune(childNode)) { continue; } // Only push the node if it does have children if (this.nodeProcessor.HasMoreChildren(childNode)) { var shouldPushNode = true; if (masterThread || this.MasterThread) { shouldPushNode = !this.threadPool.TryNewThreadSearch(childNode); } if (shouldPushNode) { searchCollection.Push(childNode); } } foreach (var visitor in visitors) { visitor.Visit(childNode); } } } } if (masterThread || this.MasterThread) { this.threadPool.WaitAll(); } }