std.parallelism changes done

Sönke Ludwig ludwig at informatik.uni-luebeck.de
Thu Mar 24 00:00:01 PDT 2011


Am 24.03.2011 05:32, schrieb dsimcha:
> In addition to improving the documentation, I added
> Task.executeInNewThread() to allow Task to be useful without a TaskPool.
> (Should this have a less verbose name?)

The threading system I designed for the company I work for uses priority 
per task to control which tasks can overtake others. A special priority 
is out-of-bands (the name my be debatable), which will guarantee that 
the task will run in its own thread so it can safely wait for other 
tasks. However, those threads that process OOB tasks are also cached in 
the thread pool and reused for new OOB tasks. Only if the number of 
parallel OOB tasks goes over a specific number, new threads will be 
created and destroyed. This can safe quite a bit of time for those tasks.

Both kinds of priority have been very useful and I would suggest to put 
at least the executeInNewThread() method into ThreadPool to be later 
able to make such an optimization.

The task priority thing in general may only be necessary for complex 
applications with user interaction, where you have to statisfy certain 
interactivity needs. I wouldn't be too sad if this is not implemented 
now, but it would be good to keep it in mind as a possible improvement 
for later.

Sönke


More information about the Digitalmars-d mailing list