ThreadPool

Inherited: Object

Description

Public Methods

int

maxThreads () const

void

setMaxThreads (int number)

void

start (Object & object)

bool

waitForDone (int32_t msecs = -1)

Static Methods

int

optimalThreadCount ()

Methods Description

int ThreadPool::maxThreads () const

Returns the max number of threads allocated to work.

See also setMaxThreads().


int ThreadPool::optimalThreadCount ()

Returns the optimal thread count for the current system. This value is based on the number of CPU cores.


void ThreadPool::setMaxThreads (int number)

Sets the max number of threads allocated to work.

See also maxThreads().


void ThreadPool::start (Object & object)

Pushes an object to thread pool. In case of any free worker available executes task immediately.


bool ThreadPool::waitForDone (int32_t msecs = -1)

Waits up to msecs milliseconds for all threads to exit and removes all threads from the thread pool. Returns true if all threads were removed; otherwise it returns false. If msecs is -1 (the default), the timeout is ignored (waits for the last thread to exit).