I was browsing through some Design Patterns over the internet, and I recently came across the Thread Pool pattern. My natural reaction was to google around for some implementations.
I liked Blake Thompson's win32 implementation on Intel's website. Inspired from it, I thought of writing an implementation for unix/linux platform.
ThreadPool class manages all the ThreadPool related activities. This includes keeping track of idle threads and synchronizations between all threads.
ThreadPool class uses a WorkerThread class.
Now this WorkerThread is having a virtual function executeThis().
The user needs to subclass WorkerThread and implement executeThis() to assign the tasks.
You can download the code and documentation from http://code.google.com/p/cppthreadpool/
This code is licensed under GPL v3. So feel free to use it, modify it, and whatever it.
I have currently tested it under cygwin environment, but I am expecting it to work in unix and linux environments as well (since it uses POSIX threads). It will be great if someone with unix/linux environment can test it.
If you have any doubts about how to use this Thread Pool implementation, then please feel free to ask me at shobhitgupta12@gmail.com