Function async_std::task::yield_now

source ·
pub async fn yield_now()
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;