Function embedded_runtime::context::sleep_once

source ·
pub async fn sleep_once()
Expand description

A function that can be polled once before it becomes ready; useful to suspend the current context and up a timeslice to the runtime/other pending futures

§Behaviour

Awaiting this function yields immediately WITHOUT WAKING THE WAKER AGAIN, making room for other futures to execute. This is useful to e.g. suspend the execution of the current routine if it cannot make any progress and has no associated event sources.

§Important

Unlike spin_once, this function DOES NOT wake the waker again. If the runtime enters deep-sleep, you MUST ensure there are other pending futures or event sources to wake it up again.