Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
pool_queue_adapter.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
13#pragma once
14
15#include <memory>
16#include <vector>
17#include <string>
18
23
24namespace kcenon::thread {
25
26// Forward declarations
27class job_queue;
28
29template<typename SyncPolicy, typename BoundPolicy, typename OverflowPolicy>
30class policy_queue;
31
49public:
50 virtual ~pool_queue_adapter_interface() = default;
51
57 [[nodiscard]] virtual auto enqueue(std::unique_ptr<job>&& job) -> common::VoidResult = 0;
58
64 [[nodiscard]] virtual auto enqueue_batch(std::vector<std::unique_ptr<job>>&& jobs) -> common::VoidResult = 0;
65
70 [[nodiscard]] virtual auto dequeue() -> common::Result<std::unique_ptr<job>> = 0;
71
76 [[nodiscard]] virtual auto try_dequeue() -> common::Result<std::unique_ptr<job>> = 0;
77
82 [[nodiscard]] virtual auto empty() const -> bool = 0;
83
88 [[nodiscard]] virtual auto size() const -> std::size_t = 0;
89
93 virtual auto clear() -> void = 0;
94
98 virtual auto stop() -> void = 0;
99
104 [[nodiscard]] virtual auto is_stopped() const -> bool = 0;
105
110 [[nodiscard]] virtual auto get_capabilities() const -> queue_capabilities = 0;
111
116 [[nodiscard]] virtual auto to_string() const -> std::string = 0;
117
126 [[nodiscard]] virtual auto get_job_queue() const -> std::shared_ptr<job_queue> = 0;
127
132 [[nodiscard]] virtual auto get_scheduler() -> scheduler_interface& = 0;
133
138 [[nodiscard]] virtual auto get_scheduler() const -> const scheduler_interface& = 0;
139};
140
141} // namespace kcenon::thread
A thread-safe job queue for managing and dispatching work items.
Definition job_queue.h:65
Represents a unit of work (task) to be executed, typically by a job queue.
Definition job.h:136
Abstract interface for queue adapters used by thread_pool.
virtual auto enqueue(std::unique_ptr< job > &&job) -> common::VoidResult=0
Enqueue a job.
virtual auto to_string() const -> std::string=0
Get string representation.
virtual auto is_stopped() const -> bool=0
Check if queue is stopped.
virtual auto try_dequeue() -> common::Result< std::unique_ptr< job > >=0
Try to dequeue a job (non-blocking)
virtual auto get_scheduler() -> scheduler_interface &=0
Get the underlying scheduler interface.
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 clear() -> void=0
Clear all jobs from queue.
virtual auto stop() -> void=0
Stop the queue.
virtual auto get_capabilities() const -> queue_capabilities=0
Get queue capabilities.
virtual auto get_job_queue() const -> std::shared_ptr< job_queue >=0
Get the underlying job_queue if this adapter wraps one.
virtual auto empty() const -> bool=0
Check if queue is empty.
virtual auto size() const -> std::size_t=0
Get queue size.
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.
Definition thread_impl.h:17
STL namespace.
Mixin interface for queue capability introspection.
Abstract scheduler interface for queuing and retrieving jobs.
Runtime-queryable queue capabilities descriptor.