Class ThreadPool
Defined in File thread_pool.h
Class Documentation
-
class ThreadPool
Implements a thread pool with a fixed number of threads.
Public Functions
-
explicit ThreadPool(size_t thread_count = std::max(1u, std::thread::hardware_concurrency()))
Creates a new thread pool with the a number of workers.
- Parameters:
thread_count – number of worker threads
-
ThreadPool(ThreadPool const &other) = delete
-
ThreadPool &operator=(ThreadPool const &other) = delete
-
template<typename Callable, typename ...Args>
std::future<std::result_of_t<Callable(Args...)>> add_task(Callable &&callable, Args&&... args) Adds a callable task to the task queue.
- Parameters:
callable – the executable task
args – the additional arguments for the task
- Returns:
std::future containing the result of the computation
-
explicit ThreadPool(size_t thread_count = std::max(1u, std::thread::hardware_concurrency()))