|
NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
|
异步操作取消槽 更多...
#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_token & | get_token () const noexcept |
| 获取关联的 stop_token | |
| bool | has_slot () const noexcept |
| 检查是否有取消能力 | |
异步操作取消槽
每个异步操作可以绑定一个 cancellation_slot。 当关联的 stop_source 请求停止时,取消回调被触发, 操作会被清理并且 handler 以 operation_aborted 错误码调用。
在文件 cancellation_slot.hpp 第 38 行定义.
|
inlineexplicit |
|
inline |
注册取消回调
| Handler | 回调类型 |
| handler | 取消时执行的回调 |
在文件 cancellation_slot.hpp 第 73 行定义.
引用了 neforce::forward(), is_cancelled() , 以及 neforce::make_shared().