1#ifndef NEFORCE_CORE_ASYNC_STRAND_HPP__
2#define NEFORCE_CORE_ASYNC_STRAND_HPP__
16NEFORCE_BEGIN_NAMESPACE__
45 bool expected =
false;
49 auto handler = self->queue_.try_pop();
52 self->ctx->post([self, shared_handler]() {
55 self->drain_one(self);
82 impl_->queue_.push(
move(handler));
83 impl_->drain_one(impl_);
94 bool expected =
false;
98 impl_->drain_one(impl_);
119NEFORCE_END_NAMESPACE__
void post(handler_type handler)
投递 handler 到 strand 队列末尾
io_context::executor get_executor() const noexcept
获取关联的 io_context 执行器
void dispatch(handler_type handler)
尽可能在当前线程同步执行 handler
function< void()> handler_type
handler 类型
io_context & context() const noexcept
获取关联的 io_context 引用
strand(io_context &ctx)
构造 strand
constexpr auto memory_order_release
释放内存顺序常量
constexpr auto memory_order_acquire
获取内存顺序常量
constexpr auto memory_order_relaxed
宽松内存顺序常量
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)))
移动范围元素