|
Lunchbox
1.17.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>
Collaboration diagram for lunchbox::ThreadPool:Public Member Functions | |
| ThreadPool (const size_t size) | |
| Construct a new 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 |
Static Public Member Functions | |
| static ThreadPool & | getInstance () |
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.
| lunchbox::ThreadPool::ThreadPool | ( | const size_t | size | ) |
Construct a new ThreadPool.
| size | number of threads in the thread pool |
| lunchbox::ThreadPool::~ThreadPool | ( | ) |
Destroy this thread pool.
Will block until all the tasks are done.
|
static |
| size_t lunchbox::ThreadPool::getSize | ( | ) | const |
| bool lunchbox::ThreadPool::hasPendingJobs | ( | ) | const |
|
inline |
Post a new task in the thread pool.
Definition at line 95 of file threadPool.h.
|
inline |
Post a detached task in the thread pool.
The result of this task is not monitored.
Definition at line 112 of file threadPool.h.