Skip to main content

sleep

Function sleep 

Source
pub async fn sleep(duration: Duration)
Expand description

Pause the current task for at least duration.

§Panics

Panics if called outside of an auralis task context (i.e. not from within a future spawned via TaskScope::spawn or spawn_global).

§Example

use std::time::Duration;
use auralis_task::timer;

scope.spawn(async {
    timer::sleep(Duration::from_millis(500)).await;
    // ... do something after delay
});