Skip to main content

Module multi

Module multi 

Source
Expand description

A multi-threaded, priority-aware executor (feature std).

MultiExecutor runs Send futures on a fixed set of worker threads that share one ready queue:

  • Priorities. A worker always takes the ready task with the highest priority; tasks of equal priority run in the order they became ready (FIFO), as on the single-core Executor. Priorities can change while a task waits; it is re-queued under its new priority without losing its place among equals.
  • Fairness. Strict priorities starve: a busy high-priority task can keep lower ones from ever running. With MultiExecutor::with_fairness(n), every n-th task a worker takes is the one that has been ready the longest, whatever its priority. A ready task then waits at most about n times the number of tasks ahead of it in age order.
  • Bounded cooperation. A task that never awaits cannot be interrupted by any cooperative executor. #[psync::graph(yield_every = N)] inserts yield_now every N loop iterations of an async function, so long loops give the scheduler a chance to run higher-priority work.

Wakes are never lost: a task woken while it is being polled is re-queued as soon as the poll returns (the usual idle / queued / running / notified state machine).

Structsยง

Cell ๐Ÿ”’
CellWaker ๐Ÿ”’
MultiExecutor
A priority-aware executor running Send futures on worker threads.
MultiHandle
Changes the priority of, wakes, or checks a task of a MultiExecutor.
Queue ๐Ÿ”’
Shared ๐Ÿ”’

Constantsยง

DONE ๐Ÿ”’
IDLE ๐Ÿ”’
NOTIFIED ๐Ÿ”’
QUEUED ๐Ÿ”’
RUNNING ๐Ÿ”’

Functionsยง

run ๐Ÿ”’
wake ๐Ÿ”’

Type Aliasesยง

Job ๐Ÿ”’