GrPPI  0.3.1
Generic and Reusable Parallel Pattern Interface
Public Member Functions | List of all members
grppi::worker_pool Class Reference

Pool of worker threads. This class offers a simple pool of worker threads. More...

#include <worker_pool.h>

Public Member Functions

 worker_pool (int num_threads) noexcept
 Creates a worker pool with a number of threads. More...
 
 ~worker_pool () noexcept
 Destructs the worker pool after joining with all threads in the pool. More...
 
 worker_pool (worker_pool &&) noexcept=default
 
worker_pooloperator= (worker_pool &&) noexcept=default
 
template<typename E , typename F , typename... Args>
void launch (const E &ex, F f, Args &&...args)
 Launch a function in the pool. More...
 
template<typename E , typename F , typename... Args>
void launch_tasks (const E &ex, F &&f, Args &&...args)
 
void wait () noexcept
 Wait until all launched tasks have been completed. More...
 

Detailed Description

Pool of worker threads. This class offers a simple pool of worker threads.

Note
Current version does not support more threads than the initially set number of threads.

Constructor & Destructor Documentation

grppi::worker_pool::worker_pool ( int  num_threads)
inlinenoexcept

Creates a worker pool with a number of threads.

Parameters
num_threadsNumber of threads for the pool.
grppi::worker_pool::~worker_pool ( )
inlinenoexcept

Destructs the worker pool after joining with all threads in the pool.

grppi::worker_pool::worker_pool ( worker_pool &&  )
defaultnoexcept

Member Function Documentation

template<typename E , typename F , typename... Args>
void grppi::worker_pool::launch ( const E &  ex,
f,
Args &&...  args 
)
inline

Launch a function in the pool.

Template Parameters
EExecution policy type.
FType for launched function.
ArgsType for launched function arguments.
Parameters
exExecution policy.
fFunction to be launched.
argsArguments for launched function.
template<typename E , typename F , typename... Args>
void grppi::worker_pool::launch_tasks ( const E &  ex,
F &&  f,
Args &&...  args 
)
inline
worker_pool& grppi::worker_pool::operator= ( worker_pool &&  )
defaultnoexcept
void grppi::worker_pool::wait ( )
inlinenoexcept

Wait until all launched tasks have been completed.

Postcondition
Number of workers is 0.

The documentation for this class was generated from the following file: