|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Lock-free synchronization policy using Michael-Scott algorithm. More...
#include <sync_policies.h>

Classes | |
| struct | node |
Public Types | |
| using | policy_tag = sync_policy_tag |
Public Member Functions | |
| lockfree_sync_policy () | |
| Construct lock-free sync policy. | |
| ~lockfree_sync_policy () | |
| Destructor. | |
| lockfree_sync_policy (const lockfree_sync_policy &)=delete | |
| lockfree_sync_policy & | operator= (const lockfree_sync_policy &)=delete |
| lockfree_sync_policy (lockfree_sync_policy &&)=delete | |
| lockfree_sync_policy & | operator= (lockfree_sync_policy &&)=delete |
| auto | enqueue (std::unique_ptr< job > &&value) -> common::VoidResult |
| Enqueue a job (wait-free) | |
| auto | dequeue () -> common::Result< std::unique_ptr< job > > |
| Dequeue a job (lock-free) | |
| auto | try_dequeue () -> common::Result< std::unique_ptr< job > > |
| Try to dequeue a job (non-blocking, same as dequeue for lock-free) | |
| auto | empty () const -> bool |
| Check if queue appears empty (approximate) | |
| auto | size () const -> std::size_t |
| Get approximate queue size. | |
| auto | clear () -> void |
| Clear queue (best effort for lock-free) | |
| auto | stop () -> void |
| Stop the queue (sets shutdown flag) | |
| auto | is_stopped () const -> bool |
| Check if queue is stopped. | |
| auto | set_notify (bool) -> void |
| Set notify flag (no-op for lock-free) | |
Static Public Member Functions | |
| static constexpr auto | get_capabilities () -> queue_capabilities |
| Queue capabilities for lock-free sync policy. | |
Private Attributes | |
| std::atomic< node * > | head_ |
| std::atomic< node * > | tail_ |
| std::atomic< bool > | shutdown_ |
| std::atomic< std::size_t > | approximate_size_ |
Lock-free synchronization policy using Michael-Scott algorithm.
Provides high-throughput operations without locking. Size and empty checks are approximate.
Definition at line 211 of file sync_policies.h.
Definition at line 213 of file sync_policies.h.
|
inline |
Construct lock-free sync policy.
Definition at line 233 of file sync_policies.h.
|
inline |
Destructor.
Definition at line 242 of file sync_policies.h.
References head_, kcenon::thread::policies::lockfree_sync_policy::node::next, and shutdown_.
|
delete |
|
delete |
|
inline |
Clear queue (best effort for lock-free)
Definition at line 363 of file sync_policies.h.
References dequeue().

|
inlinenodiscard |
Dequeue a job (lock-free)
Definition at line 304 of file sync_policies.h.
References approximate_size_, kcenon::thread::policies::lockfree_sync_policy::node::data, head_, kcenon::thread::policies::lockfree_sync_policy::node::next, and tail_.
Referenced by clear(), and try_dequeue().

|
inlinenodiscard |
Check if queue appears empty (approximate)
Definition at line 346 of file sync_policies.h.
References head_, and kcenon::thread::policies::lockfree_sync_policy::node::next.
|
inlinenodiscard |
Enqueue a job (wait-free)
| value | Job to enqueue |
Definition at line 265 of file sync_policies.h.
References approximate_size_, kcenon::thread::policies::lockfree_sync_policy::node::next, shutdown_, and tail_.
|
inlinestaticnodiscardconstexpr |
Queue capabilities for lock-free sync policy.
Definition at line 218 of file sync_policies.h.
Referenced by kcenon::thread::policies::adaptive_sync_policy::get_capabilities().

|
inlinenodiscard |
Check if queue is stopped.
Definition at line 383 of file sync_policies.h.
References shutdown_.
|
delete |
|
delete |
|
inline |
Set notify flag (no-op for lock-free)
| notify | Ignored |
Definition at line 391 of file sync_policies.h.
|
inlinenodiscard |
Get approximate queue size.
Definition at line 356 of file sync_policies.h.
References approximate_size_.
|
inline |
Stop the queue (sets shutdown flag)
Definition at line 375 of file sync_policies.h.
References shutdown_.
|
inlinenodiscard |
Try to dequeue a job (non-blocking, same as dequeue for lock-free)
Definition at line 338 of file sync_policies.h.
References dequeue().

|
mutableprivate |
Definition at line 407 of file sync_policies.h.
|
private |
Definition at line 404 of file sync_policies.h.
Referenced by dequeue(), empty(), lockfree_sync_policy(), and ~lockfree_sync_policy().
|
private |
Definition at line 406 of file sync_policies.h.
Referenced by enqueue(), is_stopped(), stop(), and ~lockfree_sync_policy().
|
private |
Definition at line 405 of file sync_policies.h.
Referenced by dequeue(), enqueue(), and lockfree_sync_policy().