HiPipe
0.7.0
C++17 data pipeline with Python bindings.
|
A simple thread pool class. More...
#include <hipipe/core/thread.hpp>
Public Member Functions | |
thread_pool (unsigned n_threads=std::thread::hardware_concurrency()) | |
template<typename Fun , typename... Args> | |
std::future< std::result_of_t< Fun(Args...)> > | enqueue (Fun fun, Args... args) |
~thread_pool () | |
A simple thread pool class.
This class manages the given number of threads across which it automatically distributes the given tasks.
Definition at line 30 of file thread.hpp.
|
inline |
Spawn the given number of threads and start processing the queue.
n_threads | The number of threads to be spawned. |
Definition at line 41 of file thread.hpp.
|
inline |
Thread pool destructor.
The destructor blocks until all the enqueued tasks are finished.
Definition at line 86 of file thread.hpp.
|
inline |
Enqueue a function for processing.
fun | The function to be executed. |
args | Parameters for the function. Note that they are taken by value. |
Definition at line 66 of file thread.hpp.