|
libstp
Robotics library for Botball
|
#include <thread_pool.hpp>
Public Member Functions | |
| ThreadPool (std::size_t worker_count=0) | |
| ~ThreadPool () | |
| ThreadPool (const ThreadPool &)=delete | |
| ThreadPool & | operator= (const ThreadPool &)=delete |
| template<typename F, typename... Args> | |
| auto | submit (F &&fn, Args &&... args) -> std::future< std::invoke_result_t< std::decay_t< F >, std::decay_t< Args >... > > |
| void | wait_idle () |
| Block until the queue is empty and no tasks are in flight. | |
| void | shutdown () |
| Stop accepting new tasks and join all workers. Idempotent. | |
| std::size_t | worker_count () const noexcept |
Fixed-size worker pool for short-lived tasks.
Workers are jthreads (jthread on platforms that ship it, a minimal compat fallback otherwise); the destructor requests stop, drains the queue, and joins. Submitted tasks return a std::future so callers can await results or exceptions.
Intended for fan-out compute (e.g. parallel motion-controller updates or sensor preprocessing). It is NOT a general-purpose async runtime — blocking I/O or unbounded waits will starve the pool.
Definition at line 29 of file thread_pool.hpp.
|
explicit |
| libstp::threading::ThreadPool::~ThreadPool | ( | ) |
|
delete |
|
delete |
| void libstp::threading::ThreadPool::shutdown | ( | ) |
Stop accepting new tasks and join all workers. Idempotent.
|
inline |
Submit a callable; returns a future for the result. Throws std::runtime_error if the pool has already been shut down.
Definition at line 41 of file thread_pool.hpp.
| void libstp::threading::ThreadPool::wait_idle | ( | ) |
Block until the queue is empty and no tasks are in flight.
|
inlinenodiscardnoexcept |
Definition at line 62 of file thread_pool.hpp.