Namespaces
Variants

std::stop_source:: stop_source

From cppreference.net
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
Safe reclamation
Hazard pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11) (deprecated in C++20)
(C++11) (deprecated in C++20)
Memory ordering
(C++11) (deprecated in C++26)
Free functions for atomic operations
Free functions for atomic flags
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 如果无法为停止状态分配内存。