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

Scheduler interface for queuing and retrieving jobs. More...

#include <scheduler_interface.h>

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

Public Member Functions

virtual ~scheduler_interface ()=default
 
virtual auto schedule (std::unique_ptr< job > &&work) -> common::VoidResult=0
 Enqueue a job for processing.
 
virtual auto get_next_job () -> common::Result< std::unique_ptr< job > >=0
 Dequeue the next available job.
 

Detailed Description

Scheduler interface for queuing and retrieving jobs.

This interface defines the contract for job scheduling implementations, allowing different scheduling strategies (FIFO, priority-based, etc.) to be plugged into the thread system.

Thread Safety

Implementations must ensure thread-safe access to all methods:

  • schedule() must be safely callable from multiple threads concurrently
  • get_next_job() must be safely callable from multiple worker threads
  • Internal queue state must be protected with appropriate synchronization
  • Implementations should document their specific thread safety guarantees

Typical Usage

auto scheduler = get_scheduler();
// Thread 1: Schedule jobs
auto result = scheduler->schedule(std::make_unique<my_job>());
// Thread 2: Retrieve and process jobs
auto job_result = scheduler->get_next_job();
if (job_result.is_ok()) {
auto job = std::move(job_result).value();
job->execute();
}
Represents a unit of work (task) to be executed, typically by a job queue.
Definition job.h:136
A template class representing either a value or an error.
Examples
queue_capabilities_sample.cpp.

Definition at line 52 of file scheduler_interface.h.

Constructor & Destructor Documentation

◆ ~scheduler_interface()

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

Member Function Documentation

◆ get_next_job()

virtual auto kcenon::thread::scheduler_interface::get_next_job ( ) -> common::Result< std::unique_ptr< job > >
pure virtual

Dequeue the next available job.

Returns
common::Result containing the next job or error if queue is empty/stopped

Thread Safety: Must be thread-safe, callable from multiple worker threads

Implemented in kcenon::thread::adaptive_job_queue, kcenon::thread::detail::lockfree_job_queue, kcenon::thread::job_queue, and kcenon::thread::policy_queue< SyncPolicy, BoundPolicy, OverflowPolicy >.

◆ schedule()

virtual auto kcenon::thread::scheduler_interface::schedule ( std::unique_ptr< job > && work) -> common::VoidResult
pure virtual

Enqueue a job for processing.

Parameters
workJob to schedule for execution
Returns
common::VoidResult indicating success or error

Thread Safety: Must be thread-safe, callable from any thread

Implemented in kcenon::thread::adaptive_job_queue, kcenon::thread::detail::lockfree_job_queue, kcenon::thread::job_queue, and kcenon::thread::policy_queue< SyncPolicy, BoundPolicy, OverflowPolicy >.


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