std.parallelism: How to wait all tasks finished?

Cooler kulkin at hotbox.ru
Sun Feb 2 23:01:12 PST 2014


On Monday, 3 February 2014 at 06:56:35 UTC, Dan Killebrew wrote:
>>  // Next line will block execution until all tasks already in 
>> queue finished.
>>  // Almost all what I need, but new tasks will not be started.
>>  taskPool.finish(true);
>> }
>
> Are you sure TaskPool.finish isn't what you're looking for?
>
> "Signals worker threads to terminate when the queue becomes 
> empty."
>
> It seems to me that worker threads will continue as long as the 
> queue isn't empty. So if a task adds another task to the pool, 
> some worker will process the newly enqueued task.

No. After taskPool.finish() no way to add new tasks to the queue. 
taskPool.put will not add new tasks.


More information about the Digitalmars-d-learn mailing list