std :: async::pool
Struct std::ThreadPool
struct ThreadPool {
unsigned long long mu;
unsigned long long work_cv;
unsigned long long done_cv;
?&TaskHeader qhead;
?&TaskHeader qtail;
int live;
int stopping;
int nthreads;
int idle;
unsigned long long tids[ASYNC_POOL_MAX_THREADS];
struct TimerQueue timers;
long long polls;
}Fields
guards the queue, live, the flags
signalled when a task is queued (or on shutdown)
broadcast when a task finishes
run queue, linked through TaskHeader::next
spawned and not finished
workers waiting for work
statistics
Methods
A pool with no threads yet. Put it where it will stay, then start().
Start 'n' worker threads (1..ASYNC_POOL_MAX_THREADS). 0 on success.
F and T must be Send: the task runs (and finishes) on a worker thread.
Run 'fut' as a task on the pool and wait (this thread blocks) for its value. Call from outside the pool's workers.
Block until every spawned task has finished.
Stop the workers (after their current poll) and join them. Tasks still queued or waiting are abandoned, not dropped.
= drop()