Expand description
Tasks: spawning, their handles and ids, cancellation from anywhere, and yielding. Tasks: spawning (named, or on a worker the caller names, or neither), their handles and ids, cancellation from anywhere, and yielding to the other tasks of the shard.
Re-exports§
pub use crate::runtime::spawn;pub use crate::runtime::spawn_blocking;pub use crate::runtime::spawn_local;
Modules§
- coop
- Cooperative scheduling: the budget of operations each poll of a task may
complete before it yields to the other tasks of its shard. IO that
completes spends one, and so do the receives, acquires and locks of
syncthat complete without queueing (see its module docs).
Structs§
- Abort
Handle - Cancels a task from anywhere: made by
Task::abort_handle, cloned and sent freely, and it outlives theTask. It keeps the task’s memory, not its future: an aborted task’s future is dropped where the task runs. - Access
Error - The key was read where no scope set it.
- Builder
- Spawns tasks with options: a name, kept with the task’s id while the
task lives and shown to the runtime’s task hooks
(
TaskMeta::name), and the worker to place it on. Every spawn answers an error where the free functions panic. - Fallible
Task - A spawned task whose output is
Nonewhen the task ended without one. - Id
- A task’s id: unique among the tasks of the process, never reused.
- Join
- The future of
Task::join: the task’s output, or why there is none. - Join
Error - Why a task gave no output: it was cancelled (by its handle, an
AbortHandle, or its runtime shutting down), or its future panicked. - JoinSet
- A set of spawned tasks, joined in the order they finish.
- Local
Key - A task-local key, declared with
task_local!. - Task
- A spawned task.
- Task
Local Future - The future of
LocalKey::scope.
Functions§
- id
- The id of the task this code runs in.
- try_id
- The id of the task this code runs in,
Noneoutside a task (inblock_on’s own future, or on a blocking-pool thread). - yield_
now - Gives the other tasks of this shard a turn: the task goes to the back of
its shard’s run queue and runs again after the tasks queued before it. In
block_on’s own future it lets the shard run its queue once.