Skip to main content

sleep_thread

Function sleep_thread 

pub fn sleep_thread(duration: Duration) -> Result<(), Error>
Expand description

Park the calling thread for duration: the sanctioned replacement for std::thread::sleep. Async code awaits sleep instead.

For desktop-only waits — a headless capture pumping a decoder, a device poller on its own thread. A browser page has one thread and cannot park; there this returns at once with an error, where std::thread::sleep panics.

§Errors

Error::UiThread on the web.