yield_local

Function yield_local 

Source
pub async fn yield_local()
Expand description

Yields to allow other tasks in the same executor to run.

This is an async function. Call it as yield_local().await.

This function yields execution to allow other tasks in the same LocalSet to run.

ยงExample

use sansio_executor::{LocalExecutorBuilder, spawn_local, yield_local};

LocalExecutorBuilder::default().run(async {
    spawn_local(async {
        println!("Task 1 starting");
        yield_local().await;  // Let other tasks run
        println!("Task 1 resuming");
    });

    spawn_local(async {
        println!("Task 2 running");
    });
});