a lightweight thread pool Modified from https://github.com/progschj/ThreadPool
More...
#include "NAGASH::ThreadPool.h"
|
| ThreadPool (size_t) |
| Construct the ThreadPool object with the given number of threads.
|
|
| ~ThreadPool () |
| Destruct the ThreadPool object, also joining all threads.
|
|
template<class F , class... Args> |
auto | enqueue (F &&f, Args &&...args) -> std::future< typename std::invoke_result_t< F, Args... > > |
| Add a task to the thread pool.
|
|
a lightweight thread pool Modified from https://github.com/progschj/ThreadPool
Definition at line 24 of file ThreadPool.h.
◆ ThreadPool()
NAGASH::ThreadPool::ThreadPool |
( |
size_t |
threads | ) |
|
|
inline |
Construct the ThreadPool object with the given number of threads.
- Parameters
-
threads | number of threads to launch. |
Definition at line 48 of file ThreadPool.h.
◆ ~ThreadPool()
NAGASH::ThreadPool::~ThreadPool |
( |
| ) |
|
|
inline |
◆ enqueue()
template<class F , class... Args>
auto NAGASH::ThreadPool::enqueue |
( |
F && |
f, |
|
|
Args &&... |
args |
|
) |
| -> std::future<typename std::invoke_result_t<F, Args...>> |
Add a task to the thread pool.
- Template Parameters
-
F | can be deduced by the compiler. |
...Args | can be deduced by the compiler. |
- Parameters
-
f | the function to run. |
...args | the arguments to pass to the function. |
- Returns
- the std::future of the function.
Definition at line 82 of file ThreadPool.h.
◆ condition
std::condition_variable NAGASH::ThreadPool::condition |
|
private |
◆ queue_mutex
std::mutex NAGASH::ThreadPool::queue_mutex |
|
private |
◆ stop
bool NAGASH::ThreadPool::stop |
|
private |
◆ tasks
std::queue<std::function<void()> > NAGASH::ThreadPool::tasks |
|
private |
◆ workers
std::vector<std::thread> NAGASH::ThreadPool::workers |
|
private |
The documentation for this class was generated from the following file: