pub enum TaskStep<'t> {
Show 15 variants
Yield,
Recv(ChanId),
Send(ChanId, RtPayload),
TrySend(ChanId, RtPayload),
TryRecv(ChanId),
Select(Vec<SelectArm>),
Sleep(u64),
NewChan(Option<usize>),
Spawn(Box<dyn Task<'t> + 't>),
SpawnDesc {
func: u16,
args: Vec<RtPayload>,
want_handle: bool,
},
Await(TaskId),
Abort(TaskId),
Close(ChanId),
IoPending,
Exit(RtPayload),
}Expand description
What a task asks the scheduler to do after a poll.
Variants§
Yield
Cooperative yield — re-enqueue me behind the other ready tasks.
Recv(ChanId)
Block until a value can be received from ch; resume with that value
(delivered as TaskCtx::resumed_with).
Send(ChanId, RtPayload)
Block until ch has room, then hand it payload; resume.
TrySend(ChanId, RtPayload)
Non-blocking send: hand payload to ch if it can be taken right now
(a waiting receiver or room in the buffer); resume immediately with
RtPayload::Bool(true) on success, Bool(false) if it would have blocked.
TryRecv(ChanId)
Non-blocking receive: resume immediately with a value if one is available
(in TaskCtx::resumed_with), or RtPayload::Nothing if the channel is empty.
Select(Vec<SelectArm>)
Block on a choice over several arms; resume with the winning arm’s index
in TaskCtx::selected_arm (and its value in resumed_with for a recv arm).
Sleep(u64)
Block for ticks logical ticks.
NewChan(Option<usize>)
Create a channel with the given capacity; resume immediately with its
ChanId (delivered in TaskCtx::new_chan).
Spawn(Box<dyn Task<'t> + 't>)
Spawn a child task; resume immediately with its TaskId (in TaskCtx::spawned).
SpawnDesc
Spawn a child by descriptor (function index + already-materialised
arguments) rather than a boxed body — resume with its TaskId. The boxed
TaskStep::Spawn cannot cross an OS-thread boundary (the body is !Send);
the work-stealing driver uses this Send form so any worker can build the
child locally from the descriptor. (The cooperative driver builds inline and
keeps using Spawn.)
Await(TaskId)
Block until task TaskId finishes; resume with its result payload
(Nothing if that task was aborted). Backs awaiting a task handle.
Abort(TaskId)
Cancel task TaskId (backs Stop handle); resume immediately. The
aborted task never polls again and its awaiters observe an aborted result.
Close(ChanId)
Close channel ChanId; resume immediately. Subsequent receives on the
drained channel return Nothing rather than blocking.
IoPending
Blocked on external async I/O (a network await — Connect/Listen/peer
messaging) that the scheduler itself cannot service: it has no reactor. The task is
parked BlockedIo and re-polled by the async drive loop after it yields to the host
reactor (tokio natively, the browser event loop on wasm). A purely channel/timer
program never produces this, so its behavior is byte-identical.
Exit(RtPayload)
Finished, with a result payload.