Expand description
Task scopes, task handles, and the task-safety rule at their boundary.
The Language Card states the whole contract this module implements:
Concurrent work belongs to a task scope. Leaving the scope waits for or cancels its child tasks. Immutable task-safe values such as arrays may cross task boundaries. A vector cannot cross, even through
let; finish it as an array or wrap mutable state inSharedor another synchronized type. Closures are task-safe only when every capture is.
ADR 0008 runs a spawned task on a thread of its own, so a handle here owns
that thread: the body starts when the task is created and the value it
produces is reachable only by joining it, which is what await and
leaving a scope both do. The state machine still holds no scheduling
policy — Tasking below is what decides when a task is joined, and both
evaluators reach it — because a value is observable through await or
scope exit and through nothing else.
A task’s handle belongs to the thread that spawned it: Task is Rc
and its state is a RefCell, because only the spawning task ever
touches it. What crosses the boundary is the body on the way in and the
value on the way out, both as a Transfer, plus a Cancellation the
child observes at its own safepoints.
Structs§
- NotTask
Safe - The first value in a capture that may not cross a task boundary.
- Task
- A spawned unit of work and the value it will produce.
- Task
Scope - The task scope
scope name { ... }binds. - Transfer
Closure - The parts of a
Closurea receiving task can own.
Enums§
- Task
State - What a spawned task has done so far.
- Transfer
- A task-safe value in the form the receiving task can own.
Constants§
- TASK_
SAFETY_ RULE - The Language Card sentence every task-safety diagnostic quotes.
Type Aliases§
- Task
Outcome - What a task thread hands back to the task that spawned it: the value the body produced, in the form that may cross the boundary, or why it stopped.