Preliminary. ThinkMeta ConcurrentTasks and this documentation are preliminary; everything is subject to change.

Priorities

The default scheduler knows two priorities, TaskPriority::Normal and ::High. High work is always taken before normal work.

Choosing a priority

  • AddTask and Schedule take a priority. TaskPriority::Default inherits the calling task's priority, or Normal when the caller is not a task.
  • Inside a task, SetTaskPriority changes the priority of the calling task.

What High is for

Give High to the tasks on the critical path — the serial stage of a pipeline that everything else waits for, the task that hands out work to the others. Normal tasks then fill the remaining time. In the showcases built on ConcurrentTasks, raising the serial stages to High is one of the simplest and most effective steps.

Warning

There is no aging. A steady stream of runnable High work starves Normal tasks completely. Keep High for short, essential work.

Yielding to high priority

A long-running normal task can let waiting high-priority work through with YieldTask(YieldFlags::HigherPriority); it returns at once if no high-priority work is waiting. See Yielding.

TaskSwap

The TaskSwap scheduler ignores priorities.

See also