You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version
List the versions of all tokio crates you are using. The easiest way to get
this information is using cargo tree subcommand:
tokio v1.36.0
Platform
Darwin MacBook-Pro.local 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:55:06 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6020 arm64
Description
I set the code for Duration:: from secs (0) and expect the delay of the tokio sleep to be 0, as if the sleep executed for 1ms. At present, the code that sleep (0) does not sleep does not take effect
use std::time::Duration;use simple_log::info;#[tokio::main]asyncfnmain(){
simple_log::console("debug").unwrap();info!("hello");for _ in1..1000{let d = Duration::from_secs(0);
tokio::time::sleep(d).await;}info!("world");}
I haven't looked in depth; however, sleep is permitted sleep for an arbitrary amount of time. It isn't so much a bug as a behavior discussion. I would check past issues related to sleep zero. I remember there was an issue where doing so would unexpectedly not yield. I could see a sleep(0) doing a yield_now. My guess is previously, yield_now was not guaranteed to return back to the runtime, so we couldn't use it. I believe it does now.
@baoyachi could you do some historical searching through github for sleep(0) issues and report back?
Version
List the versions of all
tokio
crates you are using. The easiest way to getthis information is using
cargo tree
subcommand:tokio v1.36.0
Platform
Darwin MacBook-Pro.local 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:55:06 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6020 arm64
Description
I set the code for Duration:: from secs (0) and expect the delay of the tokio sleep to be 0, as if the sleep executed for 1ms. At present, the code that sleep (0) does not sleep does not take effect
the output:
The text was updated successfully, but these errors were encountered: