Struct Step

Source
pub struct Step<'exec, 'fut, F, P> { /* private fields */ }
Expand description

A non-blocking executor-future-park state machine.

All executor operations are ultimately implemented with Step. It allows fine-grained control over execution and control flow. Step can only perform one poll step at a time and requires a pinned future. A Step object is created by calling Executor::step().

See Executor::block_on() for a blocking runner.

Implementations§

Source§

impl<F, P> Step<'_, '_, F, P>
where F: Future, P: FnMut(Park<'_>) -> Parked<'_>,

Source

pub fn poll(&mut self) -> Poll<F::Output>

Perform at most one non-blocking polling attempt.

This method never blocks unless the park function does (or the future, but that’s totally wrong anyway). The future will be polled given any of these:

  • The wakeup signal set is zero. This is intended to provide a reset or “full scan” mechanism. In this case, the raised signal set will be hard-coded to all-ones, regardless of the current value of the event mask. Note: A side effect of this special case is that core::future::pending() and similar constructs might busy-loop depending on the particular park function.

  • Any bit in the wakeup signal set matches the event mask. The event mask is atomically frozen at the same time that this condition is check, creating the raised signal set.

The wakeup signal set is cleared just before polling the future (edge-triggering). Regardless of the poll result or if the future is polled at all, a park operation may be triggered under implementation-defined conditions. If parking occurs, it will be the last observable operation before poll() returns. The return value will be Poll::Pending if the future is not polled. Do not call call poll() again after it returns Poll::Ready.

On first call, the wakeup signal set is zero. This ensures that all driven poll functions are attempted at least once.

Auto Trait Implementations§

§

impl<'exec, 'fut, F, P> Freeze for Step<'exec, 'fut, F, P>
where P: Freeze,

§

impl<'exec, 'fut, F, P> !RefUnwindSafe for Step<'exec, 'fut, F, P>

§

impl<'exec, 'fut, F, P> !Send for Step<'exec, 'fut, F, P>

§

impl<'exec, 'fut, F, P> !Sync for Step<'exec, 'fut, F, P>

§

impl<'exec, 'fut, F, P> Unpin for Step<'exec, 'fut, F, P>
where P: Unpin,

§

impl<'exec, 'fut, F, P> !UnwindSafe for Step<'exec, 'fut, F, P>

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.