|
NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
|
串行化执行器 更多...
#include <strand.hpp>
Public 类型 | |
| using | handler_type = function<void()> |
| handler 类型 | |
Public 成员函数 | |
| strand (io_context &ctx) | |
| 构造 strand | |
| void | post (handler_type handler) |
| 投递 handler 到 strand 队列末尾 | |
| void | dispatch (handler_type handler) |
| 尽可能在当前线程同步执行 handler | |
| io_context::executor | get_executor () const noexcept |
| 获取关联的 io_context 执行器 | |
| io_context & | context () const noexcept |
| 获取关联的 io_context 引用 | |
|
inlineexplicit |
|
inlinenodiscardnoexcept |
|
inline |
尽可能在当前线程同步执行 handler
| handler | 要执行的 handler |
若当前没有其他 handler 在执行(strand 未锁定),则在调用线程立即执行 handler。 否则降级为 post(),投递到队列等待串行执行。
在文件 strand.hpp 第 93 行定义.
引用了 neforce::memory_order_acquire, neforce::memory_order_relaxed, neforce::memory_order_release, neforce::move() , 以及 post().
|
inlinenodiscardnoexcept |
|
inline |
投递 handler 到 strand 队列末尾
| handler | 要执行的 handler |
handler 保证与 strand 中其他 handler 串行执行。
在文件 strand.hpp 第 81 行定义.
引用了 neforce::move().
被这些函数引用 dispatch().