Assignments
Assignments
ThreadPool Struct Reference

#include <threads.h>

Public Types

enum  ParallelType { NONE , THREAD_POOL , ASYNC }
 
enum  ScheduleType { STATIC , DYNAMIC }
 

Static Public Member Functions

template<typename ... Functions>
static void ParallelSections (const Functions &... functions)
 
static void Parallel_for (size_t begin, size_t end, const std::function< void(unsigned int, size_t) > &iterationFunction, ScheduleType schedule=DefaultSchedule, size_t chunkSize=DefaultChunkSize)
 
static unsigned int NumThreads (void)
 
static void Init (ParallelType parallelType, unsigned int numThreads=std::thread::hardware_concurrency())
 
static void Terminate (void)
 

Static Public Attributes

static const std::vector< std::string > ParallelNames
 
static const std::vector< std::string > ScheduleNames = { "static" , "dynamic" }
 
static size_t DefaultChunkSize = 128
 
static ScheduleType DefaultSchedule = ThreadPool::DYNAMIC
 

Private Member Functions

 ThreadPool (const ThreadPool &)
 
ThreadPooloperator= (const ThreadPool &)
 

Static Private Member Functions

template<typename Function >
static void _ParallelSections (std::future< void > *futures, const Function &function)
 
template<typename Function , typename ... Functions>
static void _ParallelSections (std::future< void > *futures, const Function &function, const Functions &... functions)
 
static void _ThreadInitFunction (unsigned int thread)
 

Static Private Attributes

static bool _Close
 
static unsigned int _RemainingTasks
 
static std::mutex _Mutex
 
static std::condition_variable _WaitingForWorkOrClose
 
static std::condition_variable _DoneWithWork
 
static std::vector< std::thread > _Threads
 
static std::function< void(unsigned int) > _ThreadFunction
 
static ParallelType _ParallelType
 

Member Enumeration Documentation

◆ ParallelType

Enumerator
NONE 
THREAD_POOL 
ASYNC 

◆ ScheduleType

Enumerator
STATIC 
DYNAMIC 

Constructor & Destructor Documentation

◆ ThreadPool()

ThreadPool::ThreadPool ( const ThreadPool )
inlineprivate

Member Function Documentation

◆ _ParallelSections() [1/2]

template<typename Function >
static void ThreadPool::_ParallelSections ( std::future< void > *  futures,
const Function &  function 
)
inlinestaticprivate

◆ _ParallelSections() [2/2]

template<typename Function , typename ... Functions>
static void ThreadPool::_ParallelSections ( std::future< void > *  futures,
const Function &  function,
const Functions &...  functions 
)
inlinestaticprivate

◆ _ThreadInitFunction()

void ThreadPool::_ThreadInitFunction ( unsigned int  thread)
inlinestaticprivate

◆ Init()

void ThreadPool::Init ( ParallelType  parallelType,
unsigned int  numThreads = std::thread::hardware_concurrency() 
)
static

◆ NumThreads()

unsigned int ThreadPool::NumThreads ( void  )
static

◆ operator=()

ThreadPool & ThreadPool::operator= ( const ThreadPool )
inlineprivate

◆ Parallel_for()

void ThreadPool::Parallel_for ( size_t  begin,
size_t  end,
const std::function< void(unsigned int, size_t) > &  iterationFunction,
ScheduleType  schedule = DefaultSchedule,
size_t  chunkSize = DefaultChunkSize 
)
static

◆ ParallelSections()

template<typename ... Functions>
static void ThreadPool::ParallelSections ( const Functions &...  functions)
inlinestatic

◆ Terminate()

void ThreadPool::Terminate ( void  )
static

Member Data Documentation

◆ _Close

bool ThreadPool::_Close
staticprivate

◆ _DoneWithWork

std::condition_variable ThreadPool::_DoneWithWork
staticprivate

◆ _Mutex

std::mutex ThreadPool::_Mutex
staticprivate

◆ _ParallelType

ThreadPool::ParallelType ThreadPool::_ParallelType
staticprivate

◆ _RemainingTasks

unsigned int ThreadPool::_RemainingTasks
staticprivate

◆ _ThreadFunction

std::function< void(unsigned int) > ThreadPool::_ThreadFunction
staticprivate

◆ _Threads

std::vector< std::thread > ThreadPool::_Threads
staticprivate

◆ _WaitingForWorkOrClose

std::condition_variable ThreadPool::_WaitingForWorkOrClose
staticprivate

◆ DefaultChunkSize

size_t ThreadPool::DefaultChunkSize = 128
static

◆ DefaultSchedule

ThreadPool::ScheduleType ThreadPool::DefaultSchedule = ThreadPool::DYNAMIC
static

◆ ParallelNames

const std::vector< std::string > ThreadPool::ParallelNames
static
Initial value:
=
{
"none" ,
"thread pool" ,
"async"
}

◆ ScheduleNames

const std::vector< std::string > ThreadPool::ScheduleNames = { "static" , "dynamic" }
static

The documentation for this struct was generated from the following files: