public void TestParallelPool() { var count = ParallelPool.MaxParallelLevel * ParallelPool.MaxParallelLevel + 1; var parallelPool = new ParallelPool(ParallelPool.MaxParallelLevel); var completed = new bool[count]; parallelPool.Batch(task => { for (var i = task.TaskIndex; i < count; i += parallelPool.ParallelLevel) { DoCompute(); completed[i] = true; } }); Assert.IsTrue(completed.All(v => v)); completed = new bool[count]; parallelPool.Batch((uint)completed.Length, task => { DoCompute(); completed[task.TaskIndex] = true; }); Assert.IsTrue(completed.All(v => v)); }
public BagBasedTaskRunner(Queue <Task <T> > listOfTasks, Queue <T> ListOfResults) { tasks_ = new ParallelPool <Task <T> >(listOfTasks); results_ = ListOfResults; }