Skip to content

Commit 8a85a85

Browse files
committed
Clarify difference between unix/windows behaviour
Updated to specify the underlying syscalls
1 parent 1700ca0 commit 8a85a85

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/std/src/thread/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,14 @@ pub fn sleep_ms(ms: u32) {
775775
/// Platforms which do not support nanosecond precision for sleeping will
776776
/// have `dur` rounded up to the nearest granularity of time they can sleep for.
777777
///
778+
/// Currently, specifying a zero duration on Unix platforms returns immediately
779+
/// without invoking the underlying [`nanosleep`] syscall, whereas on Windows
780+
/// platforms the underlying [`Sleep`] syscall is always invoked.
781+
/// If the intention is to yield the current time-slice you may want to use
782+
/// [`yield_now`] instead.
783+
/// [`nanosleep`]: https://linux.die.net/man/2/nanosleep
784+
/// [`Sleep`]: https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-sleep
785+
///
778786
/// # Examples
779787
///
780788
/// ```no_run

0 commit comments

Comments
 (0)