Skip to main content

sleep

Function sleep 

Source
pub fn sleep(d: Duration)
Expand description

Sleep the current goroutine for at least d.

Parks the goroutine and lets other goroutines run; the background timer thread calls [goready][runtime::park] when the duration elapses.

Passing Duration::ZERO yields to the scheduler without sleeping.

§Panics

Debug-panics if called from outside a goroutine.

§Example

go_lib::run(|| {
    go_lib::sleep(std::time::Duration::from_millis(10));
});