An implementation of Thread pool.
More...
#include <ThreadPool.h>
An implementation of Thread pool.
- Copyright
- zlib license
- Authors
- Jakob Progsch, Václav Zeman
◆ ThreadPool()
Utils::ThreadPool::ThreadPool |
( |
| ) |
|
|
default |
◆ ~ThreadPool()
Utils::ThreadPool::~ThreadPool |
( |
| ) |
|
|
inline |
◆ add_task()
auto Utils::ThreadPool::add_task |
( |
F && |
f, |
|
|
Args &&... |
args |
|
) |
| -> std::future<typename std::result_of<F(Args...)>::type> |
Add a task to the thread.
- Parameters
-
f | An object f |
args | A list of arguments |
- Returns
- A future object
◆ add_thread()
void Utils::ThreadPool::add_thread |
( |
std::function< void()> |
initializer | ) |
|
|
inline |
Add an extra thread.
- Parameters
-
initializer | An initializer called before doing anything so that user can initialize per-thread data structures |
◆ initialize()
void Utils::ThreadPool::initialize |
( |
std::size_t |
| ) |
|
|
inline |
Create worker threads.
- Parameters
-
threads | (Optional) The number of threads |
◆ m_condvar
std::condition_variable Utils::ThreadPool::m_condvar |
|
private |
◆ m_exit
bool Utils::ThreadPool::m_exit {false} |
|
private |
◆ m_mutex
std::mutex Utils::ThreadPool::m_mutex |
|
private |
◆ m_tasks
std::queue<std::function<void()> > Utils::ThreadPool::m_tasks |
|
private |
◆ m_threads
std::vector<std::thread> Utils::ThreadPool::m_threads |
|
private |
The documentation for this class was generated from the following file: