RAI thread wrapper adding a specific destroyer allowing to master what can be done at destruction time.
More...
#include <scoped_thread.hpp>
Public Types | |
| typedef thread::id | id |
Public Member Functions | |
| BOOST_THREAD_MOVABLE_ONLY (scoped_thread) scoped_thread() BOOST_NOEXCEPT | |
| Movable only. More... | |
| template<class F , class... Args, typename = typename disable_if<is_same<typename decay<F>::type, thread>, void* >::type> | |
| scoped_thread (BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(Args)...args) | |
| scoped_thread (BOOST_THREAD_RV_REF(thread) t) BOOST_NOEXCEPT | |
| Constructor from the thread to own. More... | |
| scoped_thread (BOOST_RV_REF(scoped_thread) x) BOOST_NOEXCEPT | |
| Move constructor. More... | |
| ~scoped_thread () | |
| Destructor. More... | |
| scoped_thread & | operator= (BOOST_RV_REF(scoped_thread) x) |
| Move assignment. More... | |
| void | swap (scoped_thread &x) BOOST_NOEXCEPT |
| thread::id | get_id () const BOOST_NOEXCEPT |
| void | detach () |
| void | join () |
| thread::native_handle_type | native_handle () BOOST_NOEXCEPT |
| bool | joinable () const BOOST_NOEXCEPT |
Static Public Member Functions | |
| static unsigned | hardware_concurrency () BOOST_NOEXCEPT |
RAI thread wrapper adding a specific destroyer allowing to master what can be done at destruction time.
CallableThread: A callable void(thread&) . The default is join_if_joinable.
thread std::thread destructor terminates the program if the thread is not joinable. Having a wrapper that can join the thread before destroying it seems a natural need.
Remark: scoped_thread is not a thread as thread is not designed to be derived from as a polymorphic type. Anyway scoped_thread can be used in most of the contexts a thread could be used as it has the same non-deprecated interface with the exception of the construction.
Example:
boost::scoped_thread<> t((boost::thread(F))); t.interrupt();
| typedef thread::id boost::scoped_thread< CallableThread >::id |
|
inlineexplicit |
|
inlineexplicit |
Constructor from the thread to own.
| t | the thread to own. |
Effects: move the thread to own t.
|
inline |
Move constructor.
|
inline |
Destructor.
Effects: Call the CallableThread functor before destroying the owned thread.
|
inline |
Movable only.
Default Constructor.
Effects: wraps a not-a-thread.
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inline |
Move assignment.
References boost::move().
|
inline |
References boost::flyweights::x.