about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorJames Wright <james.wright@digital-chaos.com>2020-12-23 00:07:48 +0000
committerJames Wright <james.wright@digital-chaos.com>2021-01-15 21:18:44 +0000
commit8a85a85cea41e1e1faacb307f29b87abf935cdf3 (patch)
treeb93f83d0e63bbbba6d39e20cdb85fae8dd6a7dbd /library/std/src
parent1700ca07c6dd7becff85678409a5df6ad4cf4f47 (diff)
downloadrust-8a85a85cea41e1e1faacb307f29b87abf935cdf3.tar.gz
rust-8a85a85cea41e1e1faacb307f29b87abf935cdf3.zip
Clarify difference between unix/windows behaviour
Updated to specify the underlying syscalls
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/thread/mod.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs
index 5d65f960fcd..115919c9666 100644
--- a/library/std/src/thread/mod.rs
+++ b/library/std/src/thread/mod.rs
@@ -775,6 +775,14 @@ 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