MEL
Microthread & Execution library
mel::parallelism::ThreadPool Class Reference

Pool of threads allowing parallel execution. More...

#include <ThreadPool.h>

Classes

struct  ExecutionOpts
 
struct  ThreadPoolOpts
 

Public Types

enum class  SchedulingPolicy { SP_ROUNDROBIN , SP_BESTFIT , SP_EXPLICIT }
 

Public Member Functions

 ThreadPool (const ThreadPoolOpts &opts)
 
size_t getNumThreads () const
 
template<class TArg , class ... FTypes>
void execute (const ExecutionOpts &opts, Barrier &barrier, TArg &&arg, std::exception_ptr &except, FTypes ... functions)
 
template<class ... FTypes>
void execute (const ExecutionOpts &opts, Barrier &barrier, std::exception_ptr &except, FTypes ... functions)
 
template<class TArg , class ... FTypes>
Barrier execute (const ExecutionOpts &opts, TArg &&arg, std::exception_ptr &except, FTypes ... functions)
 
template<class ... FTypes>
Barrier execute (const ExecutionOpts &opts, std::exception_ptr &except, FTypes ... functions)
 
template<class ReturnTuple , class TArg , class ... FTypes>
void executeWithResult (const ExecutionOpts &opts, Barrier &barrier, ReturnTuple &output, TArg &&arg, std::exception_ptr &except, FTypes ... functions)
 execute given functions and return result in the tuple

 
template<class ReturnTuple , class TArg , class ... FTypes>
Barrier executeWithResult (const ExecutionOpts &opts, ReturnTuple &output, TArg &&arg, std::exception_ptr &except, FTypes ... functions)
 
template<class ReturnTuple , class ... FTypes>
Barrier executeWithResult (const ExecutionOpts &opts, ReturnTuple &output, std::exception_ptr &except, FTypes ... functions)
 
std::shared_ptr< ThreadRunnableselectThread (const ExecutionOpts &opts)
 select thread for execution based on given opts
 

Static Public Attributes

constexpr static int THREADS_USE_ALL_CORES = ::std::numeric_limits<int>::max()
 
constexpr static uint64_t THREAD_AFFINITY_ALL = -1
 

Detailed Description

Pool of threads allowing parallel execution.

Code example:

ThreadPool::ThreadPoolOpts opts;
ThreadPool myPool(opts);
ThreadPool::ExecutionOpts exopts;

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