ThreadPool

Rewrite of the ThreadPool using condition variables. FUTURE: this could be speed-up by using futures. Description of the task and associated condition+mutex would go in an external struct. Note: the interface of the thread-pool itself is not thread-safe, you cannot give orders from multiple threads at once.

Constructors

this
this(int numThreads, int maxThreads, size_t stackSize)

Creates a thread-pool.

Destructor

~this
~this()

Destroys a thread-pool.

Members

Functions

numThreads
int numThreads()
Undocumented in source. Be warned that the author may not have intended to support it.
parallelFor
void parallelFor(int count, ThreadPoolDelegate dg)

Calls the delegate in parallel, with 0..count as index. Immediate waiting for completion. If there is only one task, it is run directly on this thread. IMPORTANT to be reentrant there! widget drawn alone can then launch same threadpool.

parallelForAsync
void parallelForAsync(int count, ThreadPoolDelegate dg)

Same, but does not wait for completion. You cannot have 2 concurrent parallelFor for the same thread-pool.

waitForCompletion
void waitForCompletion()

Wait for completion of the previous parallelFor, if any.

Meta