![]() |
Home | Libraries | People | FAQ | More |
get_id()
interruption_point()
EXTENSIONinterruption_requested()
EXTENSIONinterruption_enabled()
EXTENSIONsleep()
DEPRECATEDsleep_until()
sleep_for()
yield()
disable_interruption
EXTENSIONrestore_interruption
EXTENSIONat_thread_exit()
EXTENSIONnamespace boost { namespace this_thread { thread::id get_id() noexcept; template<typename TimeDuration> void yield() noexcept; template <class Clock, class Duration> void sleep_until(const chrono::time_point<Clock, Duration>& abs_time); template <class Rep, class Period> void sleep_for(const chrono::duration<Rep, Period>& rel_time); template<typename Callable> void at_thread_exit(Callable func); // EXTENSION void interruption_point(); // EXTENSION bool interruption_requested() noexcept; // EXTENSION bool interruption_enabled() noexcept; // EXTENSION class disable_interruption; // EXTENSION class restore_interruption; // EXTENSION #if defined BOOST_THREAD_USES_DATETIME void sleep(TimeDuration const& rel_time); // DEPRECATED void sleep(system_time const& abs_time); // DEPRECATED #endif } }
#include <boost/thread/thread.hpp> namespace this_thread { thread::id get_id() noexcept; }
An instance of boost::thread::id
that represents that
currently executing thread.
boost::thread_resource_error
if an error
occurs.
#include <boost/thread/thread.hpp> namespace this_thread { void interruption_point(); }
Check to see if the current thread has been interrupted.
boost::thread_interrupted
if boost::this_thread::interruption_enabled()
and boost::this_thread::interruption_requested()
both return true
.
#include <boost/thread/thread.hpp> namespace this_thread { bool interruption_requested() noexcept; }
true
if interruption
has been requested for the current thread, false
otherwise.
Nothing.
#include <boost/thread/thread.hpp> namespace this_thread { bool interruption_enabled() noexcept; }
true
if interruption
has been enabled for the current thread, false
otherwise.
Nothing.
#include <boost/thread/thread.hpp> namespace this_thread { template<typename TimeDuration> void sleep(TimeDuration const& rel_time); void sleep(system_time const& abs_time) }
![]() |
Warning |
---|---|
DEPRECATED since 3.0.0.
Use |
Suspends the current thread until the time period specified by rel_time
has elapsed or the time
point specified by abs_time
has been reached.
boost::thread_interrupted
if the current
thread of execution is interrupted.
sleep()
is one of the predefined interruption
points.
#include <boost/thread/thread.hpp> namespace this_thread { template <class Clock, class Duration> void sleep_until(const chrono::time_point<Clock, Duration>& abs_time); namespace no_interruption_point { template <class Clock, class Duration> void sleep_until(const chrono::time_point<Clock, Duration>& abs_time); } }
Suspends the current thread until the time point specified by abs_time
has been reached.
Nothing if Clock satisfies the TrivialClock requirements and operations
of Duration do not throw exceptions. boost::thread_interrupted
if the current thread of execution is interrupted.
sleep_until()
is one of the predefined interruption
points.
no_interruption_point::sleep_until()
is NOT one of the interruption
points.
#include <boost/thread/thread.hpp> namespace this_thread { template <class Rep, class Period> void sleep_for(const chrono::duration<Rep, Period>& rel_time); namespace no_interruption_point { template <class Rep, class Period> void sleep_for(const chrono::duration<Rep, Period>& rel_time); } }
Suspends the current thread until the duration specified by rel_time
has elapsed.
Nothing if operations of chrono::duration<Rep, Period> do not
throw exceptions. boost::thread_interrupted
if the current thread of execution is interrupted.
sleep_for()
is one of the predefined interruption
points.
no_interruption_point:: sleep_for()
is NOT one of the interruption
points.
#include <boost/thread/thread.hpp> namespace this_thread { void yield() noexcept; }
Gives up the remainder of the current thread's time slice, to allow other threads to run.
Nothing.
#include <boost/thread/thread.hpp> namespace this_thread { class disable_interruption { public: disable_interruption(const disable_interruption&) = delete; disable_interruption& operator=(const disable_interruption&) = delete; disable_interruption() noexcept; ~disable_interruption() noexcept; }; }
boost::this_thread::disable_interruption
disables interruption
for the current thread on construction, and restores the prior interruption
state on destruction. Instances of disable_interruption
cannot be copied or moved.
disable_interruption() noexcept;
Stores the current state of boost::this_thread::interruption_enabled()
and disables interruption for the current thread.
boost::this_thread::interruption_enabled()
returns false
for
the current thread.
Nothing.
~disable_interruption() noexcept;
Must be called from the same thread from which *this
was constructed.
Restores the current state of boost::this_thread::interruption_enabled()
for the current thread to that prior to the construction of *this
.
boost::this_thread::interruption_enabled()
for the current thread returns the value stored in the constructor
of *this
.
Nothing.
#include <boost/thread/thread.hpp> namespace this_thread { class restore_interruption { public: restore_interruption(const restore_interruption&) = delete; restore_interruption& operator=(const restore_interruption&) = delete; explicit restore_interruption(disable_interruption& disabler) noexcept; ~restore_interruption() noexcept; }; }
On construction of an instance of boost::this_thread::restore_interruption
,
the interruption state for the current thread is restored to the interruption
state stored by the constructor of the supplied instance of boost::this_thread::disable_interruption
. When the
instance is destroyed, interruption is again disabled. Instances of restore_interruption
cannot be copied
or moved.
explicit restore_interruption(disable_interruption& disabler) noexcept;
Must be called from the same thread from which disabler
was constructed.
Restores the current state of boost::this_thread::interruption_enabled()
for the current thread to that prior to the construction of disabler
.
boost::this_thread::interruption_enabled()
for the current thread returns the value stored in the constructor
of disabler
.
Nothing.
~restore_interruption() noexcept;
Must be called from the same thread from which *this
was constructed.
Disables interruption for the current thread.
boost::this_thread::interruption_enabled()
for the current thread returns false
.
Nothing.
#include <boost/thread/thread.hpp> template<typename Callable> void at_thread_exit(Callable func);
A copy of func
is
placed in thread-specific storage. This copy is invoked when the
current thread exits (even if the thread has been interrupted).
A copy of func
has
been saved for invocation on thread exit.
std::bad_alloc
if memory cannot be allocated
for the copy of the function, boost::thread_resource_error
if any other error occurs within the thread library. Any exception
thrown whilst copying func
into internal storage.
This function is not called if the
thread was terminated forcefully using platform-specific APIs, or
if the thread is terminated due to a call to exit()
, abort()
or std::terminate()
. In particular, returning from
main()
is equivalent to call to exit()
, so will not call any functions
registered with at_thread_exit()