|
| DISPENSO_DLL_ACCESS | ThreadPool (size_t n, size_t poolLoadMultiplier=32) |
| |
| template<class Rep , class Period > |
| void | setSignalingWake (bool enable, const std::chrono::duration< Rep, Period > &sleepDuration=std::chrono::microseconds(kDefaultSleepLenUs)) |
| |
| DISPENSO_DLL_ACCESS void | resize (ssize_t n) DISPENSO_NO_THREAD_SAFETY_ANALYSIS |
| |
| ssize_t | numThreads () const |
| |
| template<typename F > |
| void | schedule (F &&f) |
| |
| template<typename F > |
| void | schedule (F &&f, ForceQueuingTag) |
| |
| template<typename Generator > |
| void | scheduleBulk (size_t count, Generator &&gen) |
| |
| DISPENSO_DLL_ACCESS | ~ThreadPool () |
| |
The basic executor for dispenso. It provides typical thread pool functionality, plus allows work stealing by related types (e.g. TaskSet, Future, etc...), which prevents deadlock when waiting for pool-recursive tasks.
Definition at line 108 of file thread_pool.h.
template<class Rep , class Period >
| void dispenso::ThreadPool::setSignalingWake |
( |
bool | enable, |
|
|
const std::chrono::duration< Rep, Period > & | sleepDuration = std::chrono::microseconds(kDefaultSleepLenUs) ) |
|
inline |
Enable or disable signaling wake functionality. If enabled, this will try to ensure that threads are woken up proactively when work has not been available and it becomes available. This function is blocking and potentially very slow. Repeated use is discouraged.
- Parameters
-
| enable | If set true, turns on signaling wake. If false, turns it off. |
| sleepDuration | If enable is true, this is the length of time a thread will wait for a signal before waking up. If enable is false, this is the length of time a thread will sleep between polling. |
- Note
- It is highly recommended to leave signaling wake enabled on Windows platforms, as sleeping/polling tends to perform poorly for intermittent workloads. For Mac/Linux platforms, it is okay to enable signaling wake, particularly if you wish to set a longer expected duration between work. If signaling wake is disabled, ensure sleepDuration is small (e.g. 200us) for best performance. Most users will not need to call this function, as defaults are reasonable.
Definition at line 138 of file thread_pool.h.