On Sun, 12 Sep 2010 15:32:13 +0200, Eric J. Holtman
On 9/12/2010 7:55 AM, Boris Schaeling wrote:
I want a worker thread to terminate if there is nothing to do. If there is something to do again and the worker thread has terminated I need to create a new one. Now I wonder if I can use boost::thread to detect whether the thread is running or not.
The reason boost::thread doesn't provide you with an "is_running" function, is that it would be nearly impossible to write it correctly.
Example:
main thread starts worker. worker starts work. main thread calls is_running which returns true.
now, before main thread can execute next statement, worker thread exits.
main thread tries to send more work to worker, who is gone.
Good point (and so obvious :)! Thanks, Boris