std::jthread::operator=

< cpp‎ | thread‎ | jthread
 
 
线程支持库
线程
(C++11)
(C++20)
(C++20)
this_thread 命名空间
(C++11)
(C++11)
(C++11)
互斥
(C++11)
通用锁管理
(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
(C++11)
(C++11)
条件变量
(C++11)
信号量
闩与屏障
(C++20)
(C++20)
future
(C++11)
(C++11)
(C++11)
(C++11)
 
 
std::jthread& operator=( std::jthread&& other ) noexcept;
(C++20 起)

*this 仍拥有关联的运行线程(即 joinable() == true ),则调用 request_stop() 然后调用 join() 。赋 other 的状态给 *this 并设置 other 为默认构造状态。

此调用后, this->get_id() 等于 other.get_id() 在调用前的值,关联的停止状态亦被移动,而 other 不再表示执行线程或拥有任何停止状态。

参数

other - 赋值给此 jthread 对象的另一 jthread 对象

返回值

*this