Thread Pooling

Sean Kelly sean at f4.ca
Sun Apr 23 12:16:00 PDT 2006


Craig Black wrote:
> I am not an expert at using threads, but I have an idea that I would like to 
> present that would perhaps make threading easier.
> 
> Thread pooling is a great way to take advantage of concurrency on multi-core 
> systems.  The number of threads in the pool could be equal to the number of 
> cores in the multi-core system.
> 
> D has a big advantage over C++ because it has nested methods, anonymous 
> methods, and delegates.  Delegates could be used with thread pools so that 
> all the programmer would have to do to start a thread would be to call a 
> method like, say, scheduleTask() and pass it a delegate.  (This could be a 
> nested method, or an anonymous method.)  The thread pool would assign the 
> task to the first thread that is idle.  scheduleTask() could return a handle 
> to a Task object.  The Task handle could be used to test to see if the task 
> is running or finished.
> 
> Comments?

I've considered this as well.  In fact, I've got library code to do this 
for C++.  But I'd prefer something a bit more forward-looking for D (see 
Herb Sutter's Concur project for one possibility).  I'm planning to 
address this need at some point in Ares, probably in a manner similar to 
the Concur design, but I don't have time at the moment.


Sean



More information about the Digitalmars-d mailing list