he code below is the public interface of the ThreadPool class.
The lines 7-10 define a light copy-by-value semantics for the class. The
instances of the class are intended for local scope usage and
passing-by-value. Each local copy points to the same structure.
The executed tasks are supplied to the ThreadPool as
boost::function0<void> objects. Such policy is defined by lines 4 and
12. The user must supply exactly the number of Jobs specified in the
constructor before calling the run() function.
The onRestart function, line 13, identifies the operation that would be
executed when some working thread is restarted.
The exit() function, line 14, commands the ThreadPool to exit next time the
executed tasks reach completion or throw.
The run() function, line 15, starts the execution. After the run() is called,
the ThreadPool becomes immutable.
The execution would continue even if all ThreadPool objects go out of scope.
1\ class ThreadPool
ThreadPool( int nThreads );
const ThreadPool& );
operator=( const ThreadPool& );
add( const Job& job );
onRestart( const Job& job );