diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2021-02-10 12:24:18 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-10 12:24:18 +0900 |
| commit | bb06b13131d71eabfd7c4cecac9c10032715e9bd (patch) | |
| tree | 81f0279bf07e6e060f2a0dd0de020bfe30adfbec /library/std/src/thread | |
| parent | ca98712ff92c56506442cd5a500547f2f0cba0c3 (diff) | |
| parent | bb2a27ba4f5880d9842d4f2af2bf02a7253f303a (diff) | |
| download | rust-bb06b13131d71eabfd7c4cecac9c10032715e9bd.tar.gz rust-bb06b13131d71eabfd7c4cecac9c10032715e9bd.zip | |
Rollup merge of #79849 - Digital-Chaos:sleep-zero, r=m-ou-se
Clarify docs regarding sleep of zero duration Clarify that the behaviour of sleep() when given a duration of zero is actually platform specific.
Diffstat (limited to 'library/std/src/thread')
| -rw-r--r-- | library/std/src/thread/mod.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 0d004a516f5..0ef848ff0c4 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -775,6 +775,15 @@ pub fn sleep_ms(ms: u32) { /// Platforms which do not support nanosecond precision for sleeping will /// have `dur` rounded up to the nearest granularity of time they can sleep for. /// +/// Currently, specifying a zero duration on Unix platforms returns immediately +/// without invoking the underlying [`nanosleep`] syscall, whereas on Windows +/// platforms the underlying [`Sleep`] syscall is always invoked. +/// If the intention is to yield the current time-slice you may want to use +/// [`yield_now`] instead. +/// +/// [`nanosleep`]: https://linux.die.net/man/2/nanosleep +/// [`Sleep`]: https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-sleep +/// /// # Examples /// /// ```no_run |
