Skip to main content

yield_now

Function yield_now 

Source
pub async fn yield_now()
Available on crate features alloc and std only.
Expand description

Cooperatively gives up a timeslice to the task scheduler.

Calling this function will move the currently executing future to the back of the execution queue, making room for other futures to execute. This is especially useful after running CPU-intensive operations inside a future.

See also task::spawn_blocking.

ยงExamples

Basic usage:

use async_std::task;

task::yield_now().await;