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>
impl<F, P> Step<'_, '_, F, P>
Sourcepub fn poll(&mut self) -> Poll<F::Output>
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.