|
PACS System 0.1.0
PACS DICOM system library
|
IExecutor implementation using kcenon::thread::thread_pool. More...
#include <executor_adapter.h>


Classes | |
| struct | delayed_task |
Public Member Functions | |
| thread_pool_executor_adapter (std::shared_ptr< kcenon::thread::thread_pool > pool) | |
| Construct adapter with thread pool. | |
| thread_pool_executor_adapter (std::size_t worker_count) | |
| Construct adapter with worker count. | |
| ~thread_pool_executor_adapter () override | |
| Destructor - ensures graceful shutdown. | |
| thread_pool_executor_adapter (const thread_pool_executor_adapter &)=delete | |
| thread_pool_executor_adapter & | operator= (const thread_pool_executor_adapter &)=delete |
| thread_pool_executor_adapter (thread_pool_executor_adapter &&)=delete | |
| thread_pool_executor_adapter & | operator= (thread_pool_executor_adapter &&)=delete |
| kcenon::common::Result< std::future< void > > | execute (std::unique_ptr< kcenon::common::interfaces::IJob > &&job) override |
| Execute a job. | |
| kcenon::common::Result< std::future< void > > | execute_delayed (std::unique_ptr< kcenon::common::interfaces::IJob > &&job, std::chrono::milliseconds delay) override |
| Execute a job with delay. | |
| std::size_t | worker_count () const override |
| Get the number of worker threads. | |
| bool | is_running () const override |
| Check if the executor is running. | |
| std::size_t | pending_tasks () const override |
| Get the number of pending tasks. | |
| void | shutdown (bool wait_for_completion=true) override |
| Shutdown the executor. | |
| template<typename F > requires std::invocable<F> | |
| auto | submit (F &&func, std::string name="submitted_job") -> kcenon::common::Result< std::future< void > > |
| Submit a void-returning callable directly. | |
| auto | get_underlying_pool () const -> std::shared_ptr< kcenon::thread::thread_pool > |
| Get the underlying thread pool. | |
Private Attributes | |
| std::shared_ptr< kcenon::thread::thread_pool > | pool_ |
| std::atomic< bool > | running_ {true} |
| std::atomic< std::size_t > | pending_count_ {0} |
| std::thread | delay_thread_ |
| std::mutex | delay_mutex_ |
| std::condition_variable | delay_cv_ |
| std::atomic< bool > | shutdown_requested_ {false} |
| std::priority_queue< delayed_task, std::vector< delayed_task >, std::greater< delayed_task > > | delayed_tasks_ |
IExecutor implementation using kcenon::thread::thread_pool.
This class adapts kcenon::thread::thread_pool to the IExecutor interface, enabling standardized task execution across the pacs_system workflow modules.
Thread Safety: All public methods are thread-safe.
Definition at line 144 of file executor_adapter.h.
|
explicit |
Construct adapter with thread pool.
| pool | Existing thread pool to use |
Definition at line 30 of file executor_adapter.cpp.
References pool_.
|
explicit |
Construct adapter with worker count.
Creates a new thread pool with the specified number of workers.
| worker_count | Number of worker threads |
Definition at line 38 of file executor_adapter.cpp.
References pool_, and worker_count().

|
override |
Destructor - ensures graceful shutdown.
Definition at line 61 of file executor_adapter.cpp.
References shutdown().

|
delete |
|
delete |
|
nodiscardoverride |
Execute a job.
Submits the job to the thread pool for asynchronous execution.
| job | The job to execute |
Definition at line 65 of file executor_adapter.cpp.
References pending_count_, pool_, and running_.
|
nodiscardoverride |
Execute a job with delay.
| job | The job to execute |
| delay | The delay before execution |
Definition at line 121 of file executor_adapter.cpp.
References delay_cv_, delay_mutex_, delay_thread_, delayed_tasks_, pending_count_, pool_, running_, and shutdown_requested_.
|
nodiscard |
Get the underlying thread pool.
Definition at line 242 of file executor_adapter.cpp.
References pool_.
|
nodiscardoverride |
|
delete |
|
delete |
|
nodiscardoverride |
Get the number of pending tasks.
Definition at line 221 of file executor_adapter.cpp.
References pending_count_, and pool_.
|
override |
Shutdown the executor.
| wait_for_completion | Wait for all pending tasks to complete |
Definition at line 226 of file executor_adapter.cpp.
References delay_cv_, delay_thread_, pool_, running_, and shutdown_requested_.
Referenced by ~thread_pool_executor_adapter().

|
inlinenodiscard |
Submit a void-returning callable directly.
This is a convenience method that wraps the callable in a lambda_job.
| F | Callable type |
| func | The function to execute |
| name | Job name for logging |
Definition at line 238 of file executor_adapter.h.
References name.
|
nodiscardoverride |
Get the number of worker threads.
Definition at line 213 of file executor_adapter.cpp.
References pool_.
Referenced by thread_pool_executor_adapter().

|
private |
Definition at line 258 of file executor_adapter.h.
Referenced by execute_delayed(), and shutdown().
|
private |
Definition at line 257 of file executor_adapter.h.
Referenced by execute_delayed().
|
private |
Definition at line 256 of file executor_adapter.h.
Referenced by execute_delayed(), and shutdown().
|
private |
Definition at line 270 of file executor_adapter.h.
Referenced by execute_delayed().
|
private |
Definition at line 253 of file executor_adapter.h.
Referenced by execute(), execute_delayed(), and pending_tasks().
|
private |
Definition at line 251 of file executor_adapter.h.
Referenced by execute(), execute_delayed(), get_underlying_pool(), is_running(), pending_tasks(), shutdown(), thread_pool_executor_adapter(), thread_pool_executor_adapter(), and worker_count().
|
private |
Definition at line 252 of file executor_adapter.h.
Referenced by execute(), execute_delayed(), is_running(), and shutdown().
|
private |
Definition at line 259 of file executor_adapter.h.
Referenced by execute_delayed(), and shutdown().