Thread pool utility class.
More...
#include <threadPool.hpp>
|
| ThreadPool (uint32_t maxThreads=0) |
|
virtual | ~ThreadPool () |
|
void | start () |
|
void | stop () |
|
template<typename R, typename P = std::ratio<1>> |
void | awaitTermination (std::chrono::duration< R, P > duration) |
|
template<typename Func, typename... Args> |
void | add (Func function, Args... args) |
|
Thread pool utility class.
Number of thread can be parameterized in constructor. If not set, the maximum number of thread will be equal to the number of processor or 1.
Every thread which will be run by this way will be detach. They will be not joinable.
Thread can be retrieve through event mechanism or by specific implementation in thread function.
- Author
- Vincent Lachenal
- Since
- 0.1
◆ ThreadPool()
anch::ThreadPool::ThreadPool |
( |
uint32_t | maxThreads = 0 | ) |
|
ThreadPool constructor
- Parameters
-
maxThreads | the maximum number of alive threads (default number of processor or 1 if not defined) |
◆ ~ThreadPool()
virtual anch::ThreadPool::~ThreadPool |
( |
| ) |
|
|
virtual |
◆ add()
template<typename Func, typename... Args>
void anch::ThreadPool::add |
( |
Func | function, |
|
|
Args... | args ) |
Add a new thread in queue
- Parameters
-
function | the function which will be call in a separated thread |
args | the function arguments |
◆ awaitTermination()
template<typename R, typename P = std::ratio<1>>
void anch::ThreadPool::awaitTermination |
( |
std::chrono::duration< R, P > | duration | ) |
|
Await thread pool termination
- Parameters
-
duration | the maximum duration to wait. If <1 wait indefinitly. Default std::chrono::seconds (-1) . |
◆ start()
void anch::ThreadPool::start |
( |
| ) |
|
Start executing threads in queue
◆ stop()
void anch::ThreadPool::stop |
( |
| ) |
|
Stop executing threads in queue
The documentation for this class was generated from the following file: