|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Adapter for policy_queue to pool_queue_adapter_interface. More...
#include <policy_queue_adapter.h>


Public Types | |
| using | queue_type = policy_queue<SyncPolicy, BoundPolicy, OverflowPolicy> |
Public Member Functions | |
| policy_queue_adapter () | |
| Construct adapter with new policy_queue using default policies. | |
| policy_queue_adapter (BoundPolicy bound_policy) | |
| Construct adapter with bound policy. | |
| policy_queue_adapter (SyncPolicy sync_policy, BoundPolicy bound_policy, OverflowPolicy overflow_policy) | |
| Construct adapter with all policies. | |
| policy_queue_adapter (std::unique_ptr< queue_type > queue) | |
| Construct adapter with existing policy_queue. | |
| ~policy_queue_adapter () override=default | |
| policy_queue_adapter (const policy_queue_adapter &)=delete | |
| policy_queue_adapter & | operator= (const policy_queue_adapter &)=delete |
| policy_queue_adapter (policy_queue_adapter &&)=default | |
| policy_queue_adapter & | operator= (policy_queue_adapter &&)=default |
| auto | enqueue (std::unique_ptr< job > &&j) -> common::VoidResult override |
| Enqueue a job. | |
| auto | enqueue_batch (std::vector< std::unique_ptr< job > > &&jobs) -> common::VoidResult override |
| Enqueue a batch of jobs. | |
| auto | dequeue () -> common::Result< std::unique_ptr< job > > override |
| Dequeue a job (blocking) | |
| auto | try_dequeue () -> common::Result< std::unique_ptr< job > > override |
| Try to dequeue a job (non-blocking) | |
| auto | empty () const -> bool override |
| Check if queue is empty. | |
| auto | size () const -> std::size_t override |
| Get queue size. | |
| auto | clear () -> void override |
| Clear all jobs from queue. | |
| auto | stop () -> void override |
| Stop the queue. | |
| auto | is_stopped () const -> bool override |
| Check if queue is stopped. | |
| auto | get_capabilities () const -> queue_capabilities override |
| Get queue capabilities. | |
| auto | to_string () const -> std::string override |
| Get string representation. | |
| auto | get_job_queue () const -> std::shared_ptr< job_queue > override |
| Get the underlying job_queue if this adapter wraps one. | |
| auto | get_scheduler () -> scheduler_interface &override |
| Get the underlying scheduler interface. | |
| auto | get_scheduler () const -> const scheduler_interface &override |
| Get the underlying scheduler interface (const) | |
| auto | get_policy_queue () -> queue_type & |
| Get direct access to the underlying policy_queue. | |
| auto | get_policy_queue () const -> const queue_type & |
| Get direct access to the underlying policy_queue (const) | |
Public Member Functions inherited from kcenon::thread::pool_queue_adapter_interface | |
| virtual | ~pool_queue_adapter_interface ()=default |
Private Attributes | |
| std::unique_ptr< queue_type > | queue_ |
Adapter for policy_queue to pool_queue_adapter_interface.
This template adapter wraps any policy_queue instantiation and provides the unified interface expected by thread_pool. It enables thread_pool to work with the new policy-based queue system.
| SyncPolicy | Synchronization policy type |
| BoundPolicy | Bounding policy type |
| OverflowPolicy | Overflow handling policy type |
Definition at line 54 of file policy_queue_adapter.h.
| using kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_type = policy_queue<SyncPolicy, BoundPolicy, OverflowPolicy> |
Definition at line 56 of file policy_queue_adapter.h.
|
inline |
Construct adapter with new policy_queue using default policies.
Definition at line 61 of file policy_queue_adapter.h.
|
inlineexplicit |
Construct adapter with bound policy.
| bound_policy | Bound policy configuration |
Definition at line 68 of file policy_queue_adapter.h.
|
inline |
Construct adapter with all policies.
| sync_policy | Sync policy configuration |
| bound_policy | Bound policy configuration |
| overflow_policy | Overflow policy configuration |
Definition at line 77 of file policy_queue_adapter.h.
|
inlineexplicit |
Construct adapter with existing policy_queue.
| queue | Unique pointer to policy_queue |
Definition at line 89 of file policy_queue_adapter.h.
|
overridedefault |
|
delete |
|
default |
|
inlineoverridevirtual |
Clear all jobs from queue.
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 133 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
inlinenodiscardoverridevirtual |
Dequeue a job (blocking)
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 117 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
inlinenodiscardoverridevirtual |
Check if queue is empty.
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 125 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
inlinenodiscardoverridevirtual |
Enqueue a job.
| job | Job to enqueue |
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 102 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
inlinenodiscardoverridevirtual |
Enqueue a batch of jobs.
| jobs | Jobs to enqueue |
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 106 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
inlinenodiscardoverridevirtual |
Get queue capabilities.
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 145 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
inlinenodiscardoverridevirtual |
Get the underlying job_queue if this adapter wraps one.
This method is provided for backward compatibility with code that needs direct access to job_queue. Returns nullptr for policy_queue adapters.
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 156 of file policy_queue_adapter.h.
|
inlinenodiscard |
Get direct access to the underlying policy_queue.
Definition at line 173 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
inlinenodiscard |
Get direct access to the underlying policy_queue (const)
Definition at line 181 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
inlinenodiscardoverridevirtual |
Get the underlying scheduler interface.
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 161 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
inlinenodiscardoverridevirtual |
Get the underlying scheduler interface (const)
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 165 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
inlinenodiscardoverridevirtual |
Check if queue is stopped.
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 141 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
delete |
|
default |
|
inlinenodiscardoverridevirtual |
Get queue size.
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 129 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
inlineoverridevirtual |
Stop the queue.
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 137 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
inlinenodiscardoverridevirtual |
Get string representation.
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 149 of file policy_queue_adapter.h.
References utility_module::formatter::format(), and kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.

|
inlinenodiscardoverridevirtual |
Try to dequeue a job (non-blocking)
Implements kcenon::thread::pool_queue_adapter_interface.
Definition at line 121 of file policy_queue_adapter.h.
References kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::queue_.
|
private |
Definition at line 186 of file policy_queue_adapter.h.
Referenced by kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::clear(), kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::dequeue(), kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::empty(), kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::enqueue(), kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::enqueue_batch(), kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::get_capabilities(), kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::get_policy_queue(), kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::get_policy_queue(), kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::get_scheduler(), kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::get_scheduler(), kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::is_stopped(), kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::size(), kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::stop(), kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::to_string(), and kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >::try_dequeue().