Class ThreadPool

Nested Relationships

Nested Types

Class Documentation

class ThreadPool

a pool of threads with work stealing, an executor

Public Functions

explicit ThreadPool(std::size_t p = 0, std::int64_t spin = 2000000)

a pool of p threads, the caller included (the number of the hardware threads if 0), whose idle workers look for tasks for spin ns before they sleep

ThreadPool(const ThreadPool&) = delete
ThreadPool &operator=(const ThreadPool&) = delete
~ThreadPool()

stops the workers, which first finish their tasks

inline std::size_t concurrency(void) const

the number of threads, the caller included

template<class F>
void bulk(std::size_t n, F &&f)

f( 0 ) , … , f( n - 1 ) on the threads of the pool

template<class F, class G>
void invoke(F &&f, G &&g)

f() and g() in parallel