|
PACS System 0.1.0
PACS DICOM system library
|
Concrete implementation of thread_pool_interface. More...
#include <thread_pool_adapter.h>


Public Member Functions | |
| thread_pool_adapter (const thread_pool_config &config) | |
| Construct adapter with configuration. | |
| thread_pool_adapter (std::shared_ptr< kcenon::thread::thread_pool > pool) | |
| Construct adapter with an existing thread pool. | |
| ~thread_pool_adapter () override | |
| Destructor. | |
| thread_pool_adapter (const thread_pool_adapter &)=delete | |
| thread_pool_adapter & | operator= (const thread_pool_adapter &)=delete |
| thread_pool_adapter (thread_pool_adapter &&)=delete | |
| thread_pool_adapter & | operator= (thread_pool_adapter &&)=delete |
| auto | start () -> bool override |
| Start the thread pool. | |
| auto | is_running () const noexcept -> bool override |
| Check if the thread pool is running. | |
| void | shutdown (bool wait_for_completion=true) override |
| Shutdown the thread pool. | |
| auto | submit (std::function< void()> task) -> std::future< void > override |
| Submit a task for execution. | |
| auto | submit_with_priority (job_priority priority, std::function< void()> task) -> std::future< void > override |
| Submit a task with a specific priority level. | |
| void | submit_fire_and_forget (std::function< void()> task) override |
| Submit a task without waiting for completion. | |
| auto | get_thread_count () const -> std::size_t override |
| Get the current number of worker threads. | |
| auto | get_pending_task_count () const -> std::size_t override |
| Get the number of pending tasks in the queue. | |
| auto | get_idle_worker_count () const -> std::size_t override |
| Get the number of idle workers. | |
| auto | get_underlying_pool () const -> std::shared_ptr< kcenon::thread::thread_pool > |
| Get the underlying thread pool. | |
| auto | get_config () const noexcept -> const thread_pool_config & |
| Get the current configuration. | |
Public Member Functions inherited from kcenon::pacs::integration::thread_pool_interface | |
| virtual | ~thread_pool_interface ()=default |
| Virtual destructor for proper polymorphic destruction. | |
Private Member Functions | |
| void | submit_internal (std::function< void()> task, job_priority priority) |
| Internal task submission with priority. | |
Private Attributes | |
| std::shared_ptr< kcenon::thread::thread_pool > | pool_ |
| thread_pool_config | config_ |
| std::mutex | mutex_ |
| bool | initialized_ {false} |
Additional Inherited Members | |
Protected Member Functions inherited from kcenon::pacs::integration::thread_pool_interface | |
| thread_pool_interface ()=default | |
| Protected default constructor for derived classes. | |
| thread_pool_interface (const thread_pool_interface &)=delete | |
| Non-copyable. | |
| thread_pool_interface & | operator= (const thread_pool_interface &)=delete |
| thread_pool_interface (thread_pool_interface &&)=default | |
| Movable. | |
| thread_pool_interface & | operator= (thread_pool_interface &&)=default |
Concrete implementation of thread_pool_interface.
This class adapts kcenon::thread::thread_pool to the thread_pool_interface, enabling dependency injection for thread pool operations in PACS components.
Key features:
Thread Safety: All public methods are thread-safe.
Definition at line 65 of file thread_pool_adapter.h.
|
explicit |
Construct adapter with configuration.
Creates a new thread pool with the specified configuration. The pool is not started until start() is called.
| config | Configuration options for the thread pool |
Definition at line 28 of file thread_pool_adapter.cpp.
References config_, if(), kcenon::pacs::integration::thread_pool_config::max_threads, kcenon::pacs::integration::thread_pool_config::min_threads, pool_, and kcenon::pacs::integration::thread_pool_config::pool_name.

|
explicit |
Construct adapter with an existing thread pool.
Wraps an existing thread pool instance. This is useful for sharing a pool across multiple components or for testing.
| pool | Existing thread pool to wrap (must not be null) |
Definition at line 43 of file thread_pool_adapter.cpp.
References pool_.
|
override |
Destructor.
Shuts down the thread pool if it's still running.
Definition at line 51 of file thread_pool_adapter.cpp.
References shutdown().

|
delete |
|
delete |
|
nodiscardnoexcept |
Get the current configuration.
Definition at line 225 of file thread_pool_adapter.cpp.
References config_.
|
nodiscardoverridevirtual |
Get the number of idle workers.
Implements kcenon::pacs::integration::thread_pool_interface.
Definition at line 210 of file thread_pool_adapter.cpp.
|
nodiscardoverridevirtual |
Get the number of pending tasks in the queue.
Implements kcenon::pacs::integration::thread_pool_interface.
Definition at line 205 of file thread_pool_adapter.cpp.
|
nodiscardoverridevirtual |
Get the current number of worker threads.
Implements kcenon::pacs::integration::thread_pool_interface.
Definition at line 198 of file thread_pool_adapter.cpp.
References config_, initialized_, kcenon::pacs::integration::thread_pool_config::min_threads, and mutex_.
|
nodiscard |
Get the underlying thread pool.
Provides access to the underlying kcenon::thread::thread_pool for advanced use cases. Use with caution.
Definition at line 219 of file thread_pool_adapter.cpp.
|
nodiscardoverridevirtualnoexcept |
Check if the thread pool is running.
Implements kcenon::pacs::integration::thread_pool_interface.
Definition at line 97 of file thread_pool_adapter.cpp.
Referenced by submit_internal().

|
delete |
|
delete |
|
overridevirtual |
Shutdown the thread pool.
Stops accepting new tasks and optionally waits for pending tasks.
| wait_for_completion | If true, waits for all pending tasks to complete |
Implements kcenon::pacs::integration::thread_pool_interface.
Definition at line 102 of file thread_pool_adapter.cpp.
References initialized_, mutex_, and pool_.
Referenced by ~thread_pool_adapter().

|
nodiscardoverridevirtual |
Start the thread pool.
Initializes worker threads and begins accepting tasks. Safe to call multiple times; subsequent calls are no-ops if running.
Implements kcenon::pacs::integration::thread_pool_interface.
Definition at line 59 of file thread_pool_adapter.cpp.
Referenced by submit_internal().

|
nodiscardoverridevirtual |
Submit a task for execution.
Submits a void-returning task to the thread pool for asynchronous execution with normal priority.
| task | The task to execute (must be callable with no arguments) |
| std::runtime_error | if pool is not running |
Implements kcenon::pacs::integration::thread_pool_interface.
Definition at line 116 of file thread_pool_adapter.cpp.
References kcenon::pacs::integration::normal.
|
overridevirtual |
Submit a task without waiting for completion.
Fire-and-forget submission for tasks where the result is not needed. Errors are logged but not propagated.
| task | The task to execute |
Implements kcenon::pacs::integration::thread_pool_interface.
Definition at line 155 of file thread_pool_adapter.cpp.
References kcenon::pacs::integration::low, and submit_internal().

|
private |
Internal task submission with priority.
Definition at line 159 of file thread_pool_adapter.cpp.
References is_running(), mutex_, pool_, and start().
Referenced by submit_fire_and_forget().


|
nodiscardoverridevirtual |
Submit a task with a specific priority level.
Jobs with higher priority (lower enum value) are processed first.
| priority | The priority level for this task |
| task | The task to execute |
| std::runtime_error | if pool is not running |
Implements kcenon::pacs::integration::thread_pool_interface.
Definition at line 135 of file thread_pool_adapter.cpp.
|
private |
Definition at line 160 of file thread_pool_adapter.h.
Referenced by get_config(), get_thread_count(), and thread_pool_adapter().
|
private |
Definition at line 162 of file thread_pool_adapter.h.
Referenced by get_thread_count(), and shutdown().
|
mutableprivate |
Definition at line 161 of file thread_pool_adapter.h.
Referenced by get_idle_worker_count(), get_pending_task_count(), get_thread_count(), get_underlying_pool(), is_running(), shutdown(), and submit_internal().
|
private |
Definition at line 159 of file thread_pool_adapter.h.
Referenced by get_idle_worker_count(), get_pending_task_count(), get_underlying_pool(), is_running(), shutdown(), submit_internal(), thread_pool_adapter(), and thread_pool_adapter().