NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
neforce::cancellation_slot类 参考

异步操作取消槽 更多...

#include <cancellation_slot.hpp>

Public 类型

using cancel_handler = function<void()>
 取消回调类型

Public 成员函数

 cancellation_slot ()=default
 默认构造
 cancellation_slot (stop_token token)
 stop_token 构造
bool is_cancelled () const noexcept
 检查是否已请求取消
template<typename Handler>
bool assign (Handler &&handler)
 注册取消回调
const stop_tokenget_token () const noexcept
 获取关联的 stop_token
bool has_slot () const noexcept
 检查是否有取消能力

详细描述

异步操作取消槽

每个异步操作可以绑定一个 cancellation_slot。 当关联的 stop_source 请求停止时,取消回调被触发, 操作会被清理并且 handler 以 operation_aborted 错误码调用。

在文件 cancellation_slot.hpp38 行定义.

构造及析构函数说明

◆ cancellation_slot()

neforce::cancellation_slot::cancellation_slot ( stop_token token)
inlineexplicit

stop_token 构造

参数
token停止令牌

在文件 cancellation_slot.hpp56 行定义.

引用了 neforce::move().

成员函数说明

◆ assign()

template<typename Handler>
bool neforce::cancellation_slot::assign ( Handler && handler)
inline

注册取消回调

模板参数
Handler回调类型
参数
handler取消时执行的回调
返回
是否注册成功(已取消则返回 false 且不注册)
注解
若注册时已取消,handler 会被立即调用

在文件 cancellation_slot.hpp73 行定义.

引用了 neforce::forward(), is_cancelled() , 以及 neforce::make_shared().


该类的文档由以下文件生成: