Skip to main content

TaskStep

Enum TaskStep 

Source
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.)

Fields

§func: u16
§want_handle: bool
§

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 awaitConnect/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.

Auto Trait Implementations§

§

impl<'t> Freeze for TaskStep<'t>

§

impl<'t> !RefUnwindSafe for TaskStep<'t>

§

impl<'t> !Send for TaskStep<'t>

§

impl<'t> !Sync for TaskStep<'t>

§

impl<'t> Unpin for TaskStep<'t>

§

impl<'t> UnsafeUnpin for TaskStep<'t>

§

impl<'t> !UnwindSafe for TaskStep<'t>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.