|
HIPO
4.3.0
High Performance Output data format for experimental physics
|
A ThreadPool implementation for managing asynchronous task execution. More...
#include <threadpool.hpp>
Classes | |
| struct | Statistics |
| Runtime statistics for thread pool performance monitoring. More... | |
Public Types | |
| enum class | ShutdownResult { Graceful , Forced , AlreadyStopped } |
| Result status of thread pool shutdown. More... | |
Public Member Functions | |
| ThreadPool (std::size_t num_threads=0, std::string_view thread_name_prefix="ThreadPool") | |
| Constructs a ThreadPool with specified number of worker threads. More... | |
| ~ThreadPool () noexcept | |
| Destructor ensures graceful shutdown with reasonable timeout. More... | |
| ThreadPool (const ThreadPool &)=delete | |
| ThreadPool & | operator= (const ThreadPool &)=delete |
| ThreadPool (ThreadPool &&) noexcept | |
| ThreadPool & | operator= (ThreadPool &&) noexcept |
| template<typename Callable , typename... Args> | |
| auto | submit (Callable &&callable, Args &&... args) -> std::future< std::invoke_result_t< std::decay_t< Callable >, std::decay_t< Args >... >> |
| Submits a task for asynchronous execution. More... | |
| auto | shutdown (std::chrono::milliseconds timeout=std::chrono::seconds{5}) noexcept -> void |
| Initiates graceful shutdown with specified timeout. More... | |
| auto | wait_for_idle (std::chrono::milliseconds timeout=std::chrono::milliseconds::max()) const -> bool |
| Waits for all pending tasks to complete. More... | |
| auto | thread_count () const noexcept -> std::size_t |
| Gets the number of worker threads. More... | |
| auto | pending_tasks () const noexcept -> std::size_t |
| Gets the number of pending tasks. More... | |
| auto | is_running () const noexcept -> bool |
| Checks if the pool is running (not stopped). More... | |
| auto | get_statistics () const noexcept -> const Statistics & |
| Gets current statistics snapshot. More... | |
A ThreadPool implementation for managing asynchronous task execution.
Provides a thread pool that distributes work across multiple worker threads, with support for task submission via futures, graceful shutdown, and runtime statistics.
Definition at line 35 of file threadpool.hpp.
|
strong |
Result status of thread pool shutdown.
| Enumerator | |
|---|---|
| Graceful | All tasks completed within timeout. |
| Forced | Timeout exceeded, threads detached. |
| AlreadyStopped | Pool was already stopped. |
Definition at line 40 of file threadpool.hpp.
|
delete |
|
inlinenoexcept |
Gets current statistics snapshot.
Definition at line 139 of file threadpool.hpp.
|
inlinenoexcept |
Checks if the pool is running (not stopped).
Definition at line 134 of file threadpool.hpp.
|
delete |
|
inlinenoexcept |
Gets the number of pending tasks.
Definition at line 129 of file threadpool.hpp.
|
inlinenoexcept |
Gets the number of worker threads.
Definition at line 124 of file threadpool.hpp.