From: Moore, Dave (dmoore_at_[hidden])
Date: 2002-03-21 12:36:07


An implementation of a thread_pool (aka worker pool, worker queue) has been
uploaded to :

http://groups.yahoo.com/group/boost/files/thread_pool.zip

Documentation and examples are included.

Features:

- Implemented purely in terms of Boost.Threads
- A thread pool object can execute any function conforming to
boost::function0<void>.
- Control over the minimum and maximum number of threads used in the pool
- thread_pool is join()able
- cancel is provided, which currently cancels any unexecuted jobs, and will
eventually cancel any running jobs once boost::thread::cancel() exists.

Future Directions/Questions:

- It may be a good idea to support priorities for jobs, but this should be
done in concert with the idea of boost::thread::priority

- While detach() is included in the sample implementation for completeness,
it may not be necessary for a thread_pool. If the risks outweigh the
utility, it may be removed.

Warning:

Requires Boost 1.27.0. On win32, a deadlock can occur when adding new
functions to the thread pool for Boost 1.26.0

Thanks very much to Bill Kempf for EXTENSIVE feedback and comments on the
design.

Dave