|
NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
线程本地任务队列 更多...
#include <thread_pool.hpp>
Public 类型 | |
| enum class | steal_strategy : uint8_t { half , fixed_batch , single , adaptive } |
| 任务窃取策略 更多... | |
Public 成员函数 | |
| NEFORCE_NODISCARD size_t | capacity () const noexcept |
| 获取队列容量 | |
| NEFORCE_NODISCARD bool | empty () const noexcept |
| 检查队列是否为空 | |
| NEFORCE_NODISCARD size_t | remain_size () const noexcept |
| 获取剩余容量 | |
| NEFORCE_NODISCARD size_t | size () const noexcept |
| 获取队列当前大小 | |
| void | push_back (function< void()> task) |
| 推送任务到队列尾部 | |
| optional< function< void()> > | try_pop () |
| 从队列头部弹出任务 | |
| optional< function< void()> > | be_stolen_by (local_queue &dst_queue) |
| 被其他队列窃取任务 | |
静态 Public 成员函数 | |
| static void | set_steal_strategy (const steal_strategy strategy, const uint32_t batch_size=4) |
| 设置窃取策略 | |
静态 Public 属性 | |
| static constexpr size_t | queue_size = 256 |
| 队列容量 | |
|
strong |
任务窃取策略
| 枚举值 | |
|---|---|
| half | 窃取一半任务 |
| fixed_batch | 窃取固定数量的任务 |
| single | 每次只窃取一个任务 |
| adaptive | 自适应策略 |
在文件 thread_pool.hpp 第 87 行定义.
| optional< function< void()> > local_queue::be_stolen_by | ( | local_queue & | dst_queue | ) |
被其他队列窃取任务
| dst_queue | 目标队列 |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
推送任务到队列尾部
| task | 要推送的任务 |
在文件 thread_pool.hpp 第 175 行定义.
引用了 memory_order_relaxed, memory_order_release , 以及 move().
|
inlinenoexcept |
|
inlinestatic |
|
inlinenoexcept |