Thread pool and progress tracking utilities.
More...
Thread pool and progress tracking utilities.
◆ get_throughput()
| auto ThreadPool::Statistics::get_throughput |
( |
| ) |
const -> double |
|
inlinenoexcept |
Calculates tasks completed per second.
- Returns
- throughput as tasks per second
Definition at line 191 of file threadpool.hpp.
◆ get_uptime()
| auto ThreadPool::Statistics::get_uptime |
( |
| ) |
const -> std::chrono::duration<double> |
|
inlinenoexcept |
Calculates time elapsed since pool creation.
- Returns
- uptime as a chrono duration
Definition at line 197 of file threadpool.hpp.
◆ operator=() [1/2]
Move assignment; transfers statistics state.
Definition at line 215 of file threadpool.hpp.
◆ operator=() [2/2]
◆ shutdown()
| auto ThreadPool::shutdown |
( |
std::chrono::milliseconds |
timeout = std::chrono::seconds{5} | ) |
-> void |
|
inlinenoexcept |
Initiates graceful shutdown with specified timeout.
- Parameters
-
| timeout | Maximum time to wait for completion |
Definition at line 292 of file threadpool.hpp.
◆ Statistics()
| ThreadPool::Statistics::Statistics |
( |
Statistics && |
other | ) |
|
|
inlinenoexcept |
Move constructor; transfers statistics state.
Definition at line 201 of file threadpool.hpp.
◆ submit()
template<typename Callable , typename... Args>
| auto ThreadPool::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.
- Parameters
-
| callable | Function/callable object to execute |
| args | Arguments to pass to the callable |
- Returns
- Future for the result
- Exceptions
-
| std::runtime_error | if pool is stopped |
Definition at line 162 of file threadpool.hpp.
◆ ThreadPool() [1/2]
| ThreadPool::ThreadPool |
( |
std::size_t |
num_threads = 0, |
|
|
std::string_view |
thread_name_prefix = "ThreadPool" |
|
) |
| |
|
inlineexplicit |
Constructs a ThreadPool with specified number of worker threads.
- Parameters
-
| num_threads | Number of threads (0 = hardware_concurrency) |
| thread_name_prefix | Prefix for thread names |
- Exceptions
-
| std::system_error | if thread creation fails |
| std::invalid_argument | if num_threads > hardware limit |
Definition at line 232 of file threadpool.hpp.
◆ ThreadPool() [2/2]
◆ wait_for_idle()
| auto ThreadPool::wait_for_idle |
( |
std::chrono::milliseconds |
timeout = std::chrono::milliseconds::max() | ) |
const -> bool |
|
inline |
Waits for all pending tasks to complete.
- Parameters
-
| timeout | Maximum time to wait |
- Returns
- true if all tasks completed within timeout
Definition at line 341 of file threadpool.hpp.
◆ ~ThreadPool()
| ThreadPool::~ThreadPool |
( |
| ) |
|
|
inlinenoexcept |
Destructor ensures graceful shutdown with reasonable timeout.
Definition at line 255 of file threadpool.hpp.