|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Lock-free node freelist (Treiber stack) for node recycling. More...

Public Member Functions | |
| node_pool ()=default | |
| ~node_pool () | |
| node_pool (const node_pool &)=delete | |
| node_pool & | operator= (const node_pool &)=delete |
| node * | acquire (std::unique_ptr< job > &&job_data) |
| Acquire a node from the pool, or allocate a new one. | |
| void | release (node *n) |
| Return a retired node to the pool for reuse. | |
Private Attributes | |
| std::atomic< node * > | free_list_ {nullptr} |
Lock-free node freelist (Treiber stack) for node recycling.
Reduces heap allocations by reusing retired queue nodes. Nodes are returned to the pool via hazard pointer reclamation callbacks and acquired on enqueue instead of calling new.
Shared via shared_ptr so retire callbacks remain valid after queue destruction (the hazard pointer domain is a process-wide singleton and may invoke deleters after the queue is destroyed).
Definition at line 238 of file lockfree_job_queue.h.
|
default |
|
inline |
Definition at line 242 of file lockfree_job_queue.h.
References free_list_, and kcenon::thread::detail::lockfree_job_queue::node::next.
|
delete |
|
inline |
Acquire a node from the pool, or allocate a new one.
| job_data | Job to store in the node |
Definition at line 261 of file lockfree_job_queue.h.
References kcenon::thread::detail::lockfree_job_queue::node::data, free_list_, and kcenon::thread::detail::lockfree_job_queue::node::next.
|
delete |
|
inline |
Return a retired node to the pool for reuse.
| n | Node to recycle (must have been fully retired by HP scan) |
Definition at line 283 of file lockfree_job_queue.h.
References kcenon::thread::detail::lockfree_job_queue::node::data, free_list_, and kcenon::thread::detail::lockfree_job_queue::node::next.
|
private |
Definition at line 297 of file lockfree_job_queue.h.
Referenced by acquire(), release(), and ~node_pool().