pub fn basic_yield_now() -> impl Future<Output = ()> + Debug + SendExpand description
The minimum, executor-agnostic yield operation. This may be unsuitable for some applications.
This function is provided as a convenience for constructing a YieldProgress where no more
specific yield implementation is required. It does not itself interact with the
YieldProgress system.
§Caveat
This function implements yielding by returning a Future which will:
- The first time it is polled, immediately wake and return
Poll::Pending. - The second time it is polled, return
Poll::Ready.
This might be inadequate if the executor’s scheduling policy:
- Distinguishes intentional yielding.
For example, in Tokio 1.*, you should use
tokio::task::yield_now()instead. - Is not fair among tasks, so some amount of delay is required to successfully yield to other tasks.
- Is not fair between tasks and something else. For example, if the executor is implemented inside some event loop but itself loops through Rust async tasks as long as any of the tasks have woken, then something additional is needed to yield to the higher level.