|
|
|
|
onsider the following problem. Several threads are maintained from a manger
thread to execute given tasks repeatedly until the program is aborted. Each of
these tasks may throw boost::thread_resource_error. The boost::thread
documentation does not explain the conditions when such exception may be
thrown. However, we aim to terminate such thread and replace it with a newly
created thread. The difficulty of such operation is in passing information to
the manager thread. Indeed, if an offending thread has a thread resource
problem then it is logical to assume that any synchronization operation would
throw as well. Hence, we cannot use any mutex-protected data to pass
information between threads in such situation. Instead, we use the thread
interruption facility of the boost::thread library because the operation of
requesting an interruption of another thread never throws. Hence, the
offending thread can always singnal its condition by interrupting something.
The implementation of such thread-maintenance strategy is the
ots::scheduler::ThreadPool class.
|
|
|
|