Expand description
Task lifecycle types: TaskHeader, Task, JoinHandle.
§Memory Model
Two separate heap allocations per spawned future:
-
Arc<TaskHeader>— shared between executor (Task), allWakers, andJoinHandle. Contains the atomic state, vtable pointer, join-waker slot, and the output slot (written on completion, read by JoinHandle). -
Box<TaskBody<F>>(stored asbody_ptr: *mut ()inTaskHeader) — owns the erasedPin<Box<F>>(the live future). Freed by the executor the moment the future resolves or the task is cancelled, independent of when the JoinHandle reads the output.
Separating the output from the body lets drop_body free the future
immediately on completion while the output lives safely in the Arc until
JoinHandle::poll retrieves it.
Structs§
- Join
Handle - Future returned from
spawn(). Resolves when the spawned task completes.
Enums§
- Join
Error - Error returned by a
JoinHandlewhen the task does not complete normally.