Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
kcenon::thread::pool_queue_adapter_interface Class Referenceabstract

Abstract interface for queue adapters used by thread_pool. More...

#include <pool_queue_adapter.h>

Inheritance diagram for kcenon::thread::pool_queue_adapter_interface:
Inheritance graph
Collaboration diagram for kcenon::thread::pool_queue_adapter_interface:
Collaboration graph

Public Member Functions

virtual ~pool_queue_adapter_interface ()=default
 
virtual auto enqueue (std::unique_ptr< job > &&job) -> common::VoidResult=0
 Enqueue a job.
 
virtual auto enqueue_batch (std::vector< std::unique_ptr< job > > &&jobs) -> common::VoidResult=0
 Enqueue a batch of jobs.
 
virtual auto dequeue () -> common::Result< std::unique_ptr< job > >=0
 Dequeue a job (blocking)
 
virtual auto try_dequeue () -> common::Result< std::unique_ptr< job > >=0
 Try to dequeue a job (non-blocking)
 
virtual auto empty () const -> bool=0
 Check if queue is empty.
 
virtual auto size () const -> std::size_t=0
 Get queue size.
 
virtual auto clear () -> void=0
 Clear all jobs from queue.
 
virtual auto stop () -> void=0
 Stop the queue.
 
virtual auto is_stopped () const -> bool=0
 Check if queue is stopped.
 
virtual auto get_capabilities () const -> queue_capabilities=0
 Get queue capabilities.
 
virtual auto to_string () const -> std::string=0
 Get string representation.
 
virtual auto get_job_queue () const -> std::shared_ptr< job_queue >=0
 Get the underlying job_queue if this adapter wraps one.
 
virtual auto get_scheduler () -> scheduler_interface &=0
 Get the underlying scheduler interface.
 
virtual auto get_scheduler () const -> const scheduler_interface &=0
 Get the underlying scheduler interface (const)
 

Detailed Description

Abstract interface for queue adapters used by thread_pool.

This interface provides a unified API for both job_queue and policy_queue, allowing thread_pool to work with either queue type seamlessly.

Design Pattern

Uses the Adapter pattern to provide a common interface for different queue implementations. This enables thread_pool to be decoupled from specific queue implementations while maintaining type safety.

Thread Safety

All methods delegate to the underlying queue implementation, which must provide its own thread safety guarantees.

Definition at line 48 of file pool_queue_adapter.h.

Constructor & Destructor Documentation

◆ ~pool_queue_adapter_interface()

virtual kcenon::thread::pool_queue_adapter_interface::~pool_queue_adapter_interface ( )
virtualdefault

Member Function Documentation

◆ clear()

virtual auto kcenon::thread::pool_queue_adapter_interface::clear ( ) -> void
pure virtual

◆ dequeue()

virtual auto kcenon::thread::pool_queue_adapter_interface::dequeue ( ) -> common::Result< std::unique_ptr< job > >
nodiscardpure virtual

Dequeue a job (blocking)

Returns
Result containing the job or error

Implemented in kcenon::thread::job_queue_adapter, and kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >.

◆ empty()

virtual auto kcenon::thread::pool_queue_adapter_interface::empty ( ) const -> bool
nodiscardpure virtual

◆ enqueue()

virtual auto kcenon::thread::pool_queue_adapter_interface::enqueue ( std::unique_ptr< job > && job) -> common::VoidResult
nodiscardpure virtual

Enqueue a job.

Parameters
jobJob to enqueue
Returns
VoidResult indicating success or error

Implemented in kcenon::thread::job_queue_adapter, and kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >.

◆ enqueue_batch()

virtual auto kcenon::thread::pool_queue_adapter_interface::enqueue_batch ( std::vector< std::unique_ptr< job > > && jobs) -> common::VoidResult
nodiscardpure virtual

Enqueue a batch of jobs.

Parameters
jobsJobs to enqueue
Returns
VoidResult indicating success or error

Implemented in kcenon::thread::job_queue_adapter, and kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >.

◆ get_capabilities()

virtual auto kcenon::thread::pool_queue_adapter_interface::get_capabilities ( ) const -> queue_capabilities
nodiscardpure virtual

Get queue capabilities.

Returns
Capabilities structure

Implemented in kcenon::thread::job_queue_adapter, and kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >.

◆ get_job_queue()

virtual auto kcenon::thread::pool_queue_adapter_interface::get_job_queue ( ) const -> std::shared_ptr< job_queue >
nodiscardpure virtual

Get the underlying job_queue if this adapter wraps one.

Returns
Shared pointer to job_queue, or nullptr if not applicable

This method is provided for backward compatibility with code that needs direct access to job_queue. Returns nullptr for policy_queue adapters.

Implemented in kcenon::thread::job_queue_adapter, and kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >.

◆ get_scheduler() [1/2]

virtual auto kcenon::thread::pool_queue_adapter_interface::get_scheduler ( ) -> scheduler_interface &
nodiscardpure virtual

◆ get_scheduler() [2/2]

virtual auto kcenon::thread::pool_queue_adapter_interface::get_scheduler ( ) const -> const scheduler_interface &
nodiscardpure virtual

Get the underlying scheduler interface (const)

Returns
Const reference to scheduler_interface

Implemented in kcenon::thread::job_queue_adapter, and kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >.

◆ is_stopped()

virtual auto kcenon::thread::pool_queue_adapter_interface::is_stopped ( ) const -> bool
nodiscardpure virtual

◆ size()

virtual auto kcenon::thread::pool_queue_adapter_interface::size ( ) const -> std::size_t
nodiscardpure virtual

◆ stop()

virtual auto kcenon::thread::pool_queue_adapter_interface::stop ( ) -> void
pure virtual

◆ to_string()

virtual auto kcenon::thread::pool_queue_adapter_interface::to_string ( ) const -> std::string
nodiscardpure virtual

Get string representation.

Returns
String describing the queue

Implemented in kcenon::thread::job_queue_adapter, and kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >.

◆ try_dequeue()

virtual auto kcenon::thread::pool_queue_adapter_interface::try_dequeue ( ) -> common::Result< std::unique_ptr< job > >
nodiscardpure virtual

Try to dequeue a job (non-blocking)

Returns
Result containing the job or error

Implemented in kcenon::thread::job_queue_adapter, and kcenon::thread::policy_queue_adapter< SyncPolicy, BoundPolicy, OverflowPolicy >.


The documentation for this class was generated from the following file: