std::stop_source::stop_source
来自cppreference.com
< cpp | thread | stop source
| stop_source(); |
(1) | (C++20 起) |
| explicit stop_source( std::nostopstate_t nss ) noexcept; |
(2) | (C++20 起) |
| stop_source( const stop_source& other ) noexcept; |
(3) | (C++20 起) |
| stop_source( stop_source&& other ) noexcept; |
(4) | (C++20 起) |
构造新的 stop_source 对象。
1) 构造拥有新停止状态的
stop_source 。2) 构造无关联停止状态的空
stop_source 。3) 复制构造函数。构造拥有与
other 相同的关联停止状态的 stop_source 。4) 移动构造函数。构造拥有与
other 相同的关联停止状态的 stop_source ;将 other 设为空。参数
| nss | - | 用于构造空 stop_source 的 std::nostopstate_t 占位对象
|
| other | - | 用于构造此 stop_source 对象的另一 stop_source 对象
|
后条件
1) stop_possible() 为 true 而 stop_requested() 为 false
2) stop_possible() 与 stop_requested() 均为 false
3) *this 与
other 共享同一关联停止状态且比较相等4) *this 拥有
other 先前的关联停止状态,而 other.stop_possible() 为 false异常
1) 若不能为停止状态分配内存则为 std::bad_alloc