![]() |
Home | Libraries | People | FAQ | More |
// #include <boost/thread/scoped_thread.hpp> template <class CallableThread = join_if_joinable> class strict_scoped_thread { thread t_; // for exposition purposes only public: strict_scoped_thread(strict_scoped_thread const&) = delete; strict_scoped_thread& operator=(strict_scoped_thread const&) = delete; explicit strict_scoped_thread(thread&& t) noexcept; template <typename F&&, typename ...Args> explicit strict_scoped_thread(F&&, Args&&...); ~strict_scoped_thread(); };
RAII thread
wrapper adding a specific destroyer allowing to master what can be done at
destruction time.
CallableThread: A callable void(thread&)
.
The default is a join_if_joinable
.
Thread destructor terminates the program if the thread
is joinable. This wrapper
can be used to join the thread before destroying it.
boost::strict_scoped_thread<> t((boost::thread(F)));
explicit strict_scoped_thread(thread&& t) noexcept;
move the thread to own t_
Nothing
template <typename F&&, typename ...Args> explicit strict_scoped_thread(F&&, Args&&...);
Construct an internal thread in place.
*this.t_
refers to the newly created thread of execution and this->get_id()!=thread::id()
.
Any exception the thread construction can throw.
~strict_scoped_thread();
Equivalent to CallableThread()(t_)
.
Nothing: The CallableThread()(t_)
should not throw when joining the
thread as the scoped variable is on a scope outside the thread function.