How to specify number of worker threads for Taskpool

Sparsh Mittal sparsh0mittal at gmail.com
Sun Feb 17 08:23:14 PST 2013


I am seeing

http://dlang.org/phobos/std_parallelism.html#.TaskPool


I am running the example of parallel foreach given in that 
section.

Sorry if it is too obvious, but my question is when using


foreach(i, ref elem; taskPool.parallel(logs)) { elem = log(i + 
1.0); }

where taskPool is not explicitly defined, how do I specify number 
of worker threads? I don't know when is constructor of TaskPool 
called and hence when

///////  @trusted this(size_t nWorkers);
///////   Allows for custom number of worker threads.

function which allows for setting number of threads, is called.

I will be thankful for your help.





More information about the Digitalmars-d-learn mailing list