std::stop_source:: stop_source
From cppreference.net
<
cpp
|
thread
|
stop source
C++
Concurrency support library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::stop_source
| Member functions | ||||
|
stop_source::stop_source
|
||||
| Modifiers | ||||
| Observers | ||||
| Non-member functions | ||||
| Helper tags | ||||
|
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)
拷贝构造函数。构造一个
stop_source
,其关联的停止状态与
other
相同。
4)
移动构造函数。构造一个
stop_source
,其关联的停止状态与
other
相同;
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
如果无法为停止状态分配内存。