|
FERS 0.1.0
The Flexible Extensible Radar Simulator
|
A simple thread pool implementation. More...
#include "thread_pool.h"
Public Member Functions | |
| ThreadPool (unsigned numThreads) | |
| Constructs a ThreadPool with a specified number of threads. | |
| ~ThreadPool () | |
| Destroys the ThreadPool, joining all threads. | |
| ThreadPool (const ThreadPool &)=delete | |
| ThreadPool & | operator= (const ThreadPool &)=delete |
| ThreadPool (ThreadPool &&)=delete | |
| ThreadPool & | operator= (ThreadPool &&)=delete |
| template<class F , class... Args> | |
| std::future< std::invoke_result_t< F, Args... > > | enqueue (F &&f, Args &&... args) |
| Enqueues a task to be executed by the thread pool. | |
| void | wait () |
| Waits for all tasks in the thread pool to finish. | |
| unsigned | getAvailableThreads () |
| Returns the number of threads available for executing tasks. | |
A simple thread pool implementation.
Definition at line 28 of file thread_pool.h.
|
explicit |
Constructs a ThreadPool with a specified number of threads.
| numThreads | The number of threads in the pool. |
Definition at line 21 of file thread_pool.cpp.
References logging::ERROR, LOG, and max.
| pool::ThreadPool::~ThreadPool | ( | ) |
Destroys the ThreadPool, joining all threads.
Definition at line 64 of file thread_pool.cpp.
References max.
|
delete |
|
delete |
| std::future< std::invoke_result_t< F, Args... > > pool::ThreadPool::enqueue | ( | F && | f, |
| Args &&... | args | ||
| ) |
Enqueues a task to be executed by the thread pool.
| F | The type of the function to be executed. |
| Args | The types of the arguments to the function. |
| f | The function to be executed. |
| args | The arguments to the function. |
| std::runtime_error | if the thread pool is stopped. |
Definition at line 57 of file thread_pool.h.
References max.
| unsigned pool::ThreadPool::getAvailableThreads | ( | ) |
Returns the number of threads available for executing tasks.
Definition at line 77 of file thread_pool.cpp.
References max.
|
delete |
|
delete |
| void pool::ThreadPool::wait | ( | ) |
Waits for all tasks in the thread pool to finish.
Definition at line 82 of file thread_pool.h.
References max.