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, size_t stackSize)

Creates a thread-pool.

Destructor

~this
~this()

Destroys a thread-pool.

Members

Functions

parallelFor
void parallelFor(int count, ThreadPoolDelegate dg)

Calls the delegate in parallel, with 0..count as index. Immediate waiting for completion.

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