1#ifndef NEFORCE_CORE_ASYNC_CANCELLATION_SLOT_HPP__
2#define NEFORCE_CORE_ASYNC_CANCELLATION_SLOT_HPP__
17NEFORCE_BEGIN_NAMESPACE__
57 token_(
move(token)) {}
62 NEFORCE_NODISCARD
bool is_cancelled() const noexcept {
return token_.stop_requested(); }
72 template <
typename Handler>
78 if (!token_.stop_possible()) {
93 NEFORCE_NODISCARD
bool has_slot() const noexcept {
return token_.stop_possible(); }
98NEFORCE_END_NAMESPACE__
const stop_token & get_token() const noexcept
获取关联的 stop_token
bool assign(Handler &&handler)
注册取消回调
cancellation_slot(stop_token token)
从 stop_token 构造
bool has_slot() const noexcept
检查是否有取消能力
cancellation_slot()=default
默认构造
bool is_cancelled() const noexcept
检查是否已请求取消
function< void()> cancel_handler
取消回调类型
constexpr T && forward(remove_reference_t< T > &x) noexcept
完美转发左值
error_code make_operation_aborted() noexcept
操作已取消的错误码
static const error_category & system() noexcept
获取系统错误类别单例
@ operation_canceled
操作已取消
enable_if_t<!is_unbounded_array_v< T > &&is_constructible_v< T, Args... >, shared_ptr< T > > make_shared(Args &&... args)
融合分配创建共享指针
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__move_aux(first, last, result)))
移动范围元素