|
wxMaxima
|
A process-wide thread pool that runs BackgroundTasks, highest priority first. More...
#include <BackgroundQueue.h>
Public Member Functions | |
| BackgroundQueue (const BackgroundQueue &)=delete | |
| BackgroundQueue & | operator= (const BackgroundQueue &)=delete |
Static Public Member Functions | |
| static std::shared_ptr< BackgroundTask > | Add (BackgroundTask::Priority priority, std::function< void(stop_token)> task) |
| Enqueue a task at the given priority and return a handle to it. | |
| static int | Workers () |
| The number of worker threads the pool runs. | |
Friends | |
| class | BackgroundTask |
A process-wide thread pool that runs BackgroundTasks, highest priority first.
There is exactly one pool, created on first use and holding as many worker threads as we want to run background jobs concurrently (roughly the number of CPU cores). Submitting work via Add() never blocks the calling (usually the GUI) thread: it only appends to a queue and wakes a worker. Workers always empty the high-priority queue before touching the low-priority one, so e.g. the images of a long animation are all loaded before we start compressing the gnuplot sources behind them.
|
static |
Enqueue a task at the given priority and return a handle to it.
Does not block. If threading is impossible the task is still queued and run by a worker; callers that must run synchronously should do so themselves instead of calling Add().