101 return std::make_shared<job_queue>();
122 -> std::unique_ptr<adaptive_job_queue>
124 return std::make_unique<adaptive_job_queue>(policy);
143 -> std::unique_ptr<scheduler_interface>;
163 [[nodiscard]]
static auto create_optimal() -> std::unique_ptr<scheduler_interface>;
186 -> std::unique_ptr<standard_queue>;
202 -> std::unique_ptr<policy_lockfree_queue>;
248 template<
typename SyncPolicy,
typename BoundPolicy,
typename OverflowPolicy>
250 SyncPolicy sync_policy,
251 BoundPolicy bound_policy,
252 OverflowPolicy overflow_policy)
253 -> std::unique_ptr<policy_queue<SyncPolicy, BoundPolicy, OverflowPolicy>>
256 "SyncPolicy must be a valid sync policy type");
258 "BoundPolicy must be a valid bound policy type");
260 "OverflowPolicy must be a valid overflow policy type");
262 return std::make_unique<policy_queue<SyncPolicy, BoundPolicy, OverflowPolicy>>(
263 std::move(sync_policy),
264 std::move(bound_policy),
265 std::move(overflow_policy)
292template<
bool NeedExactSize,
bool PreferLockFree = false>
294 static_assert(!(NeedExactSize && PreferLockFree),
295 "Cannot require both exact size AND lock-free. These are mutually exclusive. "
296 "Lock-free queues cannot provide exact size due to concurrent modifications.");
300 using type = std::conditional_t<
312template<
bool NeedExactSize,
bool PreferLockFree = false>
Adaptive queue that auto-switches between mutex and lock-free modes.
Adaptive queue that switches between mutex and lock-free modes.
@ balanced
Auto-switch based on usage.
A thread-safe job queue for managing and dispatching work items.
Policy that limits queue size to a maximum.
Synchronization policy using mutex and condition variable.
Policy that rejects new items when queue is full.
Policy-based queue template.
Factory for creating queue instances.
static auto create_optimal() -> std::unique_ptr< scheduler_interface >
Create optimal queue for current environment.
static auto create_standard_queue() -> std::shared_ptr< job_queue >
Create standard job_queue.
static auto create_custom_policy_queue(SyncPolicy sync_policy, BoundPolicy bound_policy, OverflowPolicy overflow_policy) -> std::unique_ptr< policy_queue< SyncPolicy, BoundPolicy, OverflowPolicy > >
Create a policy_queue with custom policies.
static auto create_policy_queue() -> std::unique_ptr< standard_queue >
Create a standard policy_queue (mutex-based, unbounded)
static auto create_adaptive_queue(adaptive_job_queue::policy policy=adaptive_job_queue::policy::balanced) -> std::unique_ptr< adaptive_job_queue >
Create adaptive queue (RECOMMENDED for most use cases)
static auto create_bounded_policy_queue(std::size_t max_size) -> std::unique_ptr< policy_queue< policies::mutex_sync_policy, policies::bounded_policy, policies::overflow_reject_policy > >
Create a bounded policy_queue with specified size.
static auto create_lockfree_policy_queue() -> std::unique_ptr< policy_lockfree_queue >
Create a lock-free policy_queue.
static auto create_for_requirements(const requirements &reqs) -> std::unique_ptr< scheduler_interface >
Create queue based on requirements.
Thread-safe FIFO job queue with optional bounded size.
Lock-free MPMC job queue using Michael-Scott algorithm with hazard pointers.
Core threading foundation of the thread system library.
queue_t< false, false > balanced_queue_t
Queue type for balanced performance (adaptive_job_queue)
queue_t< false, true > fast_queue_t
Queue type for maximum throughput (adaptive_job_queue with performance_first policy)
queue_t< true, false > accurate_queue_t
Queue type for accurate size/empty operations (job_queue)
constexpr bool is_overflow_policy_v
Check if type is an overflow policy.
typename queue_type_selector< NeedExactSize, PreferLockFree >::type queue_t
Convenience alias for queue type selection.
constexpr bool is_bound_policy_v
Check if type is a bound policy.
constexpr bool is_sync_policy_v
Check if type is a sync policy.
Policy-based job queue template with customizable sync, bound, and overflow.
Type traits for detecting queue synchronization policy tags.
Abstract scheduler interface for queuing and retrieving jobs.
Queue selection requirements.
bool need_blocking_wait
Require blocking dequeue.
bool need_exact_size
Require exact size()
bool prefer_lock_free
Prefer lock-free if possible.
bool need_atomic_empty
Require atomic empty()
bool need_batch_operations
Require batch enqueue/dequeue.
Compile-time queue type selector.
std::conditional_t< NeedExactSize, job_queue, adaptive_job_queue > type