![]() |
Home | Libraries | People | FAQ | More |
Scoped Threads are wrappers around a thread that allows the user to state what to do at destruction time. One of the common uses is to join the thread at destruction time so this is the default behavior. This is the single difference respect to a thread. While thread call std::terminate() on the destructor if the thread is joinable, strict_scoped_thread<> or scoped_thread<> join the thread if joinable.
The difference between strict_scoped_thread and scoped_thread is that the
strict_scoped_thread hides completely the owned thread and so the user can
do nothing with the owned thread other than the specific action given as
parameter, while scoped_thread provide the same interface as thread
and forwards all the operations.
boost::strict_scoped_thread<> t1((boost::thread(f))); //t1.detach(); // compile fails boost::scoped_thread<> t2((boost::thread(f))); t2.detach();