Lunchbox
1.16.0
Multi-threaded C++ toolbox library for all application developers creating high-performance multi-threaded programs.
|
Thread pool for tasks execution. More...
#include <threadPool.h>
Public Member Functions | |
ThreadPool (const size_t size=std::max(1u, std::thread::hardware_concurrency())) | |
Construct a ThreadPool. More... | |
~ThreadPool () | |
Destroy this thread pool. More... | |
size_t | getSize () const |
template<typename F > | |
std::future< typename std::result_of< F()>::type > | post (F &&f) |
Post a new task in the thread pool. More... | |
template<typename F > | |
void | postDetached (F &&f) |
Post a detached task in the thread pool. More... | |
bool | hasPendingJobs () const |
Thread pool for tasks execution.
A task is a callable object taking no arguments and returing a value or void. All the member methods are thread safe.
Example:
Definition at line 37 of file threadPool.h.
|
inline |
Construct a ThreadPool.
size | number of threads in the thread pool |
Definition at line 19 of file threadPool.ipp.
|
inline |
Destroy this thread pool.
Will block until all the tasks are done.
Definition at line 26 of file threadPool.ipp.
|
inline |
Definition at line 36 of file threadPool.ipp.
|
inline |
Definition at line 68 of file threadPool.ipp.
|
inline |
Post a new task in the thread pool.
Definition at line 42 of file threadPool.ipp.
|
inline |
Post a detached task in the thread pool.
The result of this task is not monitored.
Definition at line 59 of file threadPool.ipp.