ClikaRT::threading::ThreadPool
class
Header: ClikaRT/threading/threading.h
ClikaRT's thread pool: schedule background work, run parallel loops, and control or query the process-wide pool that ClikaRT's compute runs on.
ClikaRT keeps one process-wide pool, sized to the host's physical cores by default (or CLIKA_RT_NUM_THREADS, see ClikaRT/common/env_vars.h). parallel_for / schedule run on it; get_thread_pool() hands back a handle to it. Its width is fixed when the pool is first created, so set CLIKA_RT_NUM_THREADS before the first compute to change it.
A handle to ClikaRT's thread pool. Get the process-wide pool with get_thread_pool(). The default ctor is hidden; handles only come from the factory. Copyable and cheap (shares the underlying pool).
Member functions
schedule()
void schedule(std::function<void()> work) const
Fire-and-forget: enqueue work to run on a pool thread. Returns immediately; there is no completion signal (use a std::promise/future in work if you need to wait for it). A throw from work is contained in your own runtime and swallowed; fire-and-forget work has no error channel, and an unwind into a pool worker would terminate.
Declared in ClikaRT/threading/threading.h, line 43
degree_of_parallelism()
int degree_of_parallelism() const
Number of worker threads (the degree of parallelism).
Declared in ClikaRT/threading/threading.h, line 63