ThreadSchedule 1.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::GlobalHighPerformancePool Class Reference

Singleton accessor for a process-wide HighPerformancePool instance. More...

#include <thread_pool.hpp>

Static Public Member Functions

static auto instance () -> HighPerformancePool &
template<typename F, typename... Args>
static auto submit (F &&f, Args &&... args)
template<typename Iterator>
static auto submit_batch (Iterator begin, Iterator end)
template<typename Iterator, typename F>
static void parallel_for_each (Iterator begin, Iterator end, F &&func)

Detailed Description

Singleton accessor for a process-wide HighPerformancePool instance.

Provides static convenience methods that forward to a single HighPerformancePool whose lifetime is managed as a function-local static (Meyer's singleton).

Thread safety
The underlying pool is created on the first call to instance() and is guaranteed to be thread-safe in C++11 and later (magic statics). All forwarded methods (submit, submit_batch, parallel_for_each) are as thread-safe as the corresponding HighPerformancePool methods.
Pool size
The pool is created with std::thread::hardware_concurrency() threads. This size is fixed for the lifetime of the process; there is no API to resize the singleton pool after creation.
Static destruction order
Because the pool is a function-local static, it is destroyed during static destruction in reverse order of construction. Submitting work to the global pool from destructors of other static objects is undefined behaviour if the pool has already been destroyed. Prefer explicit lifetime management in programs with complex static initialization dependencies.
Copyability / movability
Not instantiable (private constructor). All access is through static methods.

Definition at line 1456 of file thread_pool.hpp.

Member Function Documentation

◆ instance()

auto threadschedule::GlobalHighPerformancePool::instance ( ) -> HighPerformancePool&
inlinestatic

Definition at line 1459 of file thread_pool.hpp.

◆ parallel_for_each()

template<typename Iterator, typename F>
void threadschedule::GlobalHighPerformancePool::parallel_for_each ( Iterator begin,
Iterator end,
F && func )
inlinestatic

Definition at line 1478 of file thread_pool.hpp.

◆ submit()

template<typename F, typename... Args>
auto threadschedule::GlobalHighPerformancePool::submit ( F && f,
Args &&... args )
inlinestatic

Definition at line 1466 of file thread_pool.hpp.

◆ submit_batch()

template<typename Iterator>
auto threadschedule::GlobalHighPerformancePool::submit_batch ( Iterator begin,
Iterator end )
inlinestatic

Definition at line 1472 of file thread_pool.hpp.


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