|
MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
作用域线程类 更多...
#include <scoped_thread.hpp>
Public 类型 | |
| using | id = thread::id |
| 线程ID类型 | |
| using | native_handle_type = thread::native_handle_type |
| 原生句柄类型 | |
Public 成员函数 | |
| scoped_thread () noexcept=default | |
| 默认构造函数 | |
| template<typename Callable, typename... Args, typename = enable_if_t< !is_same_v<remove_cvref_t<Callable>, scoped_thread>>> | |
| scoped_thread (Callable &&func, Args &&... args) | |
| 构造函数 | |
| scoped_thread (const scoped_thread &)=delete | |
| 禁止拷贝构造 | |
| scoped_thread & | operator= (const scoped_thread &)=delete |
| 禁止拷贝赋值 | |
| scoped_thread (scoped_thread &&other) noexcept=default | |
| 移动构造函数 | |
| scoped_thread & | operator= (scoped_thread &&other) noexcept |
| 移动赋值运算符 | |
| ~scoped_thread () | |
| 析构函数 | |
| void | swap (scoped_thread &other) noexcept |
| 交换两个scoped_thread对象 | |
| MSTL_NODISCARD bool | joinable () const noexcept |
| 检查线程是否可被等待 | |
| void | join () |
| 等待线程结束 | |
| void | detach () |
| 分离线程 | |
| MSTL_NODISCARD id | get_id () const noexcept |
| 获取线程ID | |
| MSTL_NODISCARD native_handle_type | native_handle () const |
| 获取原生线程句柄 | |
| MSTL_NODISCARD stop_source | get_stop_source () noexcept |
| 获取停止源 | |
| MSTL_NODISCARD stop_token | get_stop_token () const noexcept |
| 获取停止令牌 | |
| bool | request_stop () noexcept |
| 请求线程停止 | |
|
defaultnoexcept |
默认构造函数
创建一个不表示任何线程的scoped_thread对象。
引用了 scoped_thread().
被这些函数引用 operator=(), operator=(), scoped_thread(), scoped_thread(), scoped_thread(), scoped_thread() , 以及 swap().
|
inlineexplicit |
构造函数
| Callable | 可调用类型 |
| Args | 参数类型 |
| func | 要在线程中执行的函数 |
| args | 传递给函数的参数 |
创建新线程并开始执行。如果函数接受stop_token参数,会自动传递。
在文件 scoped_thread.hpp 第 112 行定义.
引用了 _MSTL, forward() , 以及 scoped_thread().
|
defaultnoexcept |
|
inline |
析构函数
如果线程可被等待结束,自动请求停止并等待线程结束。
在文件 scoped_thread.hpp 第 139 行定义.
引用了 join(), joinable() , 以及 request_stop().
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inlinenoexcept |
|
inline |
|
inlinenoexcept |
移动赋值运算符
| other | 要移动的scoped_thread |
在文件 scoped_thread.hpp 第 129 行定义.
引用了 move() , 以及 scoped_thread().
|
inlinenoexcept |
请求线程停止
设置停止标志,线程可以通过检查stop_token来响应停止请求。
在文件 scoped_thread.hpp 第 220 行定义.
被这些函数引用 ~scoped_thread().
|
inlinenoexcept |
交换两个scoped_thread对象
| other | 要交换的scoped_thread |
在文件 scoped_thread.hpp 第 150 行定义.
引用了 _MSTL, scoped_thread() , 以及 swap().