|
NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
|
延迟启动线程类 更多...
#include <lazy_thread.hpp>
Public 类型 | |
| using | id = thread::id |
| 线程ID类型 | |
| using | native_handle_type = thread::native_handle_type |
| 原生句柄类型 | |
Public 成员函数 | |
| lazy_thread () noexcept=default | |
| 默认构造函数 | |
| template<typename F, typename... Args> | |
| lazy_thread (F &&f, Args &&... args) | |
| 构造函数 | |
| lazy_thread (lazy_thread &&other) noexcept | |
| 移动构造函数 | |
| lazy_thread & | operator= (lazy_thread &&other) noexcept |
| 移动赋值运算符 | |
| ~lazy_thread () | |
| 析构函数 | |
| void | start () |
| 启动线程 | |
| bool | joinable () const noexcept |
| 检查线程是否可被等待 | |
| void | join () |
| 等待线程结束 | |
| void | detach () |
| 分离线程 | |
| thread::id | get_id () const noexcept |
| 获取线程标识符 | |
| void | swap (lazy_thread &other) noexcept |
| 交换两个延迟线程对象 | |
延迟启动线程类
允许创建线程对象时仅存储可调用对象,而不立即创建和执行线程。 线程的实际创建由start()方法触发。
使用场景:
在文件 lazy_thread.hpp 第 40 行定义.
|
inlineexplicit |
构造函数
| F | 可调用对象类型 |
| Args | 参数类型 |
| f | 要执行的可调用对象 |
| args | 传递给可调用对象的参数 |
创建延迟线程对象,存储可调用对象和参数,但不立即启动线程。
在文件 lazy_thread.hpp 第 65 行定义.
引用了 neforce::apply(), neforce::forward(), lazy_thread(), neforce::make_tuple() , 以及 neforce::move().
|
noexcept |
| neforce::lazy_thread::~lazy_thread | ( | ) |
析构函数
如果线程已启动且仍可连接,会等待其完成。
|
inline |
|
inlinenodiscardnoexcept |
|
inline |
|
inlinenodiscardnoexcept |
|
noexcept |
| void neforce::lazy_thread::start | ( | ) |
|
inlinenoexcept |
交换两个延迟线程对象
| other | 要交换的对象 |
在文件 lazy_thread.hpp 第 139 行定义.
引用了 lazy_thread() , 以及 swap().
被这些函数引用 swap().