Assignments Assignments

Public Types | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
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 &)
ThreadPool & | operator= (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

enum ThreadPool::ParallelType

Enumerator
NONE |
THREAD_POOL |
ASYNC |

## ◆ ScheduleType

enum ThreadPool::ScheduleType

Enumerator
STATIC |
DYNAMIC |

## Constructor & Destructor Documentation

## ◆ ThreadPool()

ThreadPool::ThreadPool | ( | const ThreadPool & |  | ) |
| inline private

## Member Function Documentation

## ◆ _ParallelSections() [1/2]

template<typename Function >

static void ThreadPool::_ParallelSections | ( | std::future< void > * | futures,
|  | const Function & | function )
| inline static private

## ◆ _ParallelSections() [2/2]

template<typename Function , typename ... Functions>

static void ThreadPool::_ParallelSections | ( | std::future< void > * | futures,
|  | const Function & | function,
|  | const Functions &... | functions )
| inline static private

## ◆ _ThreadInitFunction()

void ThreadPool::_ThreadInitFunction | ( | unsigned int | thread | ) |
| inline static private

## ◆ 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 & |  | ) |
| inline private

## ◆ 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 | ) |
| inline static

## ◆ Terminate()

void ThreadPool::Terminate | ( | void |  | ) |
| static

## Member Data Documentation

## ◆ _Close

bool ThreadPool::_Close
| static private

## ◆ _DoneWithWork

std::condition_variable ThreadPool::_DoneWithWork
| static private

## ◆ _Mutex

std::mutex ThreadPool::_Mutex
| static private

## ◆ _ParallelType

ThreadPool::ParallelType ThreadPool::_ParallelType
| static private

## ◆ _RemainingTasks

unsigned int ThreadPool::_RemainingTasks
| static private

## ◆ _ThreadFunction

std::function< void(unsigned int) > ThreadPool::_ThreadFunction
| static private

## ◆ _Threads

std::vector< std::thread > ThreadPool::_Threads
| static private

## ◆ _WaitingForWorkOrClose

std::condition_variable ThreadPool::_WaitingForWorkOrClose
| static private

## ◆ 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:

- Assignments/Util/threads.h
- Assignments/Util/threads.cpp