目录
1.thread库概述
2.类thread
①类定义
②使用例子
3.命名空间this_thread
①空间内定义
②使用例子
4.类thread_group
①类定义
②使用例子
1.thread库 ^
Boost.Thread允许在可移植C ++代码中使用多个执行线程和共享数据。它提供了用于管理线程本身的类和函数,以及用于在线程之间同步数据或提供特定于各个线程的数据的单独副本的其他类。
#include <boost/thread/thread.hpp>
namespace boost
{
class thread;
void swap(thread& lhs,thread& rhs) noexcept;
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);
namespace no_interruption_point // 扩展
{
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); // 扩展
void interruption_point(); // 扩展
bool interruption_requested() noexcept; // 扩展
bool interruption_enabled() noexcept; // 扩展
class disable_interruption; // 扩展
class restore_interruption; // 扩展
#if defined BOOST_THREAD_USES_DATETIME
template <TimeDuration>
void sleep(TimeDuration const& rel_time); // 扩展
void sleep(system_time const& abs_time); // 扩展
#endif
}
class thread_group; // 扩展
}