命名空间
变体
操作

std::never_stop_token

来自 cppreference.cn
< cpp‎ | thread
 
 
并发支持库
线程
(C++11)
(C++20)
this_thread 命名空间
(C++11)
(C++11)
(C++11)
协同取消
(C++20)
never_stop_token
(C++26)
互斥
(C++11)
通用锁管理
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
条件变量
(C++11)
信号量
门闩和屏障
(C++20)
(C++20)
期值
(C++11)
(C++11)
(C++11)
(C++11)
安全回收
(C++26)
危险指针
原子类型
(C++11)
(C++20)
原子类型的初始化
(C++11)(C++20 中已弃用)
(C++11)(C++20 中已弃用)
内存排序
(C++11)(C++26 中已弃用)
原子操作的自由函数
原子标志的自由函数
 
定义于头文件 <stop_token>
class never_stop_token;
(C++26 起)

never_stop_token 类实现了 unstoppable_token,它提供了一个静态信息,即停止永远不可能被请求。它是 std::get_stop_token 返回的默认停止令牌类型,如果在可查询对象中没有提供其他关联的停止令牌。

目录

[编辑] 成员别名模板

类型 定义
callback_type<Callback> /*callback-type*/
其中类型定义为
struct /*callback-type*/

{
    explicit /*callback-type*/( never_stop_token,
                                auto&& ) noexcept {}

};
(仅作说明*)

[编辑] 成员函数

stop_requested
[静态]
表示停止永远不会被请求
(公共静态成员函数)
stop_possible
[静态]
表示停止是不可能的
(公共静态成员函数)
operator==
比较两个 never_stop_token 对象
(公开成员函数)

std::never_stop_token::stop_requested

static constexpr bool stop_requested() noexcept { return false; }

始终返回 false,表示停止永远不会被请求。

std::never_stop_token::stop_possible

static constexpr bool stop_possible() noexcept { return false; }

始终返回 false,表示停止是不可能的。

std::never_stop_token::operator==

bool operator==(const never_stop_token&) const = default;

两个 never_stop_token 对象总是比较相等。

[编辑] 示例