Exemple #1
0
        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();
            }
        }
Exemple #2
0
        private void PushNode(NodeModel node)
        {
            if (!prune.IsPrune(node))
            {
                // Only push the node if it does have children
                if (this.nodeProcessor.HasMoreChildren(node))
                {
                    searchCollection.Push(node);
                }

                foreach (var visitor in visitors)
                {
                    visitor.Visit(node);
                }
            }
        }