80 typename BoundPolicy = policies::unbounded_policy,
81 typename OverflowPolicy = policies::overflow_reject_policy
144 auto schedule(std::unique_ptr<job>&& work) -> common::VoidResult
override {
145 return enqueue(std::move(work));
169 [[nodiscard]]
auto enqueue(std::unique_ptr<job>&& value) -> common::VoidResult {
171 return common::error_info{-105,
"cannot enqueue null job",
"thread_system"};
175 if constexpr (BoundPolicy::is_bounded()) {
190 template<
typename JobType,
typename = std::enable_if_t<std::is_base_of_v<job, JobType>>>
191 [[nodiscard]]
auto enqueue(std::unique_ptr<JobType>&& value) -> common::VoidResult {
192 return enqueue(std::unique_ptr<job>(std::move(value)));
199 [[nodiscard]]
auto dequeue() -> common::Result<std::unique_ptr<job>> {
207 [[nodiscard]]
auto try_dequeue() -> common::Result<std::unique_ptr<job>> {
215 [[nodiscard]]
auto empty() const ->
bool {
223 [[nodiscard]]
auto size() const ->
std::
size_t {
325 return BoundPolicy::is_bounded();
333 if constexpr (BoundPolicy::is_bounded()) {
353 [[nodiscard]]
auto handle_overflow(std::unique_ptr<job>&& value) -> common::VoidResult {
354 if constexpr (std::is_same_v<OverflowPolicy, policies::overflow_reject_policy>) {
356 }
else if constexpr (std::is_same_v<OverflowPolicy, policies::overflow_drop_newest_policy>) {
358 }
else if constexpr (std::is_same_v<OverflowPolicy, policies::overflow_drop_oldest_policy>) {
366 return common::error_info{-120,
"queue is full",
"thread_system"};
403template<std::
size_t MaxSize>
413template<std::
size_t MaxSize>
423template<std::
size_t MaxSize>
Bound policies for queue capacity: unbounded or fixed-size.
Policy that limits queue size to a maximum.
Lock-free synchronization policy using Michael-Scott algorithm.
Synchronization policy using mutex and condition variable.
Policy that blocks until space is available.
Policy that drops the oldest item when queue is full.
Policy that rejects new items when queue is full.
Policy that allows unlimited queue size.
Policy-based queue template.
auto size() const -> std::size_t
Get queue size.
auto overflow_policy() -> OverflowPolicy &
Get reference to overflow policy.
auto overflow_policy() const -> const OverflowPolicy &
Get const reference to overflow policy.
auto clear() -> void
Clear all jobs from queue.
auto remaining_capacity() const -> std::size_t
Get remaining capacity.
policy_queue & operator=(const policy_queue &)=delete
auto sync_policy() const -> const SyncPolicy &
Get const reference to sync policy.
auto get_capabilities() const -> queue_capabilities override
Get queue capabilities.
auto bound_policy() -> BoundPolicy &
Get reference to bound policy.
auto bound_policy() const -> const BoundPolicy &
Get const reference to bound policy.
SyncPolicy sync_policy_type
OverflowPolicy overflow_policy_
auto try_dequeue() -> common::Result< std::unique_ptr< job > >
Try to dequeue a job (non-blocking)
auto dequeue() -> common::Result< std::unique_ptr< job > >
Dequeue a job (blocking if sync policy supports it)
auto is_full() const -> bool
Check if queue is at capacity.
auto schedule(std::unique_ptr< job > &&work) -> common::VoidResult override
Schedule a job (delegates to enqueue)
policy_queue(policy_queue &&)=delete
auto is_bounded() const -> bool
Check if queue is bounded.
policy_queue & operator=(policy_queue &&)=delete
policy_queue(SyncPolicy sync_policy, BoundPolicy bound_policy, OverflowPolicy overflow_policy)
Construct queue with all policies.
~policy_queue()=default
Destructor.
auto stop() -> void
Stop the queue.
auto get_next_job() -> common::Result< std::unique_ptr< job > > override
Get next job (delegates to dequeue)
OverflowPolicy overflow_policy_type
BoundPolicy bound_policy_type
auto empty() const -> bool
Check if queue is empty.
auto enqueue(std::unique_ptr< JobType > &&value) -> common::VoidResult
Type-safe enqueue for job subclasses.
auto is_stopped() const -> bool
Check if queue is stopped.
BoundPolicy bound_policy_
auto enqueue(std::unique_ptr< job > &&value) -> common::VoidResult
Enqueue a job into the queue.
policy_queue(const policy_queue &)=delete
policy_queue()
Construct queue with default policies.
auto sync_policy() -> SyncPolicy &
Get reference to sync policy.
auto handle_overflow(std::unique_ptr< job > &&value) -> common::VoidResult
Handle overflow based on overflow policy.
policy_queue(BoundPolicy bound_policy)
Construct queue with bound policy.
Mixin interface for queue capability introspection.
Scheduler interface for queuing and retrieving jobs.
Error codes and utilities for the thread system.
Base job class for schedulable work units in the thread system.
Core threading foundation of the thread system library.
Overflow handling policies: reject, drop-oldest, or block.
Mixin interface for queue capability introspection.
Abstract scheduler interface for queuing and retrieving jobs.
Runtime-queryable queue capabilities descriptor.
Synchronization policies: mutex-based or spinlock-based.