bieblsoft - 2013-07-24

ThreadPool is a project intended to provide a lightweight ThreadPool implementation, especially applicable in an embedded environment.

ThreadPool class is a template, which must be provided with the type of class the ThreadPool threads are intended to be used with. Since C++ lacks a common "object" base class, this is mandatory.

Consequently, you might have several ThreadPool instances for different types.

The number of Threads can be configured using a secon template parameter as well. The ThreadPool Threads will not "leave" the ThreadPool, but instead remain within it. In order to assign a task to a Thread from then Pool, we have to provide a callback method together with an object reference.

The Thread will then jump to the callback method, execute the code found there and finally return into the Pool.

Threads in waiting condition are not suspended, but actively executing an "empty" Run method.

This method checks if a callback address is provided or not.
If not, it continues looping through the Run method.
In order to reduce the overall system load as much as possible, the Run method executes a "Sleep(0)" call to signal the Scheduler it is done with it's assigned time slice.

I tried to keep the project as System-neutral as possible, but since i started on Windows, i could not avoid to use some corresponding API calls.

I intend to provide a linux based version as well as soon as possible.