Thread Pooling

Craig Black cblack at ara.com
Sun Apr 23 11:43:18 PDT 2006


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?

-Craig 





More information about the Digitalmars-d mailing list