|
Boost Users : |
Subject: Re: [Boost-users] [thread] boost::thread automatically detached when thread terminates?
From: Roland Bock (rbock_at_[hidden])
Date: 2010-09-12 09:33:06
On 09/12/2010 02:55 PM, 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.
>
> Boris
>
You might also want to think about a thread pool: A number of worker
threads which do something like this:
while(true)
{
wait_for_task;
process_task;
}
Rather simple to implement and more effective (I think) than starting a
new thread for each task. It also allows you to control the number of
total worker threads easily. It is also simple to keep track of the
number of working/waiting worker threads.
Regards,
Roland
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net