コード例 #1
0
 public JobMultiThreadSearch(VertexDistributor vertexDistributor, ISingleThreadPatternMatcherStreamed matcher, int mID, ResultProcessor resProc)
 {
     this.distributor     = vertexDistributor;
     this.matcher         = matcher;
     this.matcherID       = mID;
     this.resultProcessor = resProc;
 }
コード例 #2
0
        private void ParallelSearch()
        {
            var distributor = new VertexDistributor(this.graph.GetAllVertices(), this.helper.VerticesPerThread);

            // -1 because the last index is ment for the main app thread.
            Task[] tasks = new Task[this.helper.ThreadCount - 1];
            // Create task for each matcher except the last mather and enqueue them into thread pool.
            for (int i = 0; i < tasks.Length; i++)
            {
                var tmp = new JobMultiThreadSearch(distributor, this.matchers[i], i, this.resultProcessor);
                tasks[i] = Task.Factory.StartNew(() => WorkMultiThreadSearch(tmp));
            }

            // The last matcher is used by the main app thread.
            WorkMultiThreadSearch(new JobMultiThreadSearch(distributor, this.matchers[this.helper.ThreadCount - 1], this.helper.ThreadCount - 1, this.resultProcessor));

            Task.WaitAll(tasks);
        }
コード例 #3
0
 public JobMultiThreadSearch(VertexDistributor vertexDistributor, ISingleThreadPatternMatcher matcher)
 {
     this.distributor = vertexDistributor;
     this.matcher     = matcher;
 }