예제 #1
0
        /// <summary>
        /// Merges columns of the result table in parallel.
        /// Each thread askes for a column to merge from a column distributor.
        /// If there are no more columns to merge, the thread finishes.
        /// </summary>
        private void MergeByColumn()
        {
            var columnDistributor = new ColumnDistributor(this.results.ColumnCount);
            var mergeColumnJob    = new ParallelMergeColumnJob(columnDistributor, this.results);

            int threadsToUse = (this.helper.ThreadCount < this.results.ColumnCount ?
                                this.helper.ThreadCount : this.results.ColumnCount);

            // -1 because the main app thread will work as well.
            Task[] tasks = new Task[threadsToUse - 1];
            for (int i = 0; i < tasks.Length; i++)
            {
                tasks[i] = Task.Factory.StartNew(() => DFSParallelPatternMatcher.ParallelMergeColumnWork(mergeColumnJob));
            }

            DFSParallelPatternMatcher.ParallelMergeColumnWork(mergeColumnJob);
            Task.WaitAll(tasks);
        }
예제 #2
0
 public ParallelMergeColumnJob(ColumnDistributor columnDistributor, MatchFixedResults matcherResults)
 {
     this.matcherResults    = matcherResults;
     this.columnDistributor = columnDistributor;
 }