From 1a605a6bda22750a1be9e21b988345f343260bb6 Mon Sep 17 00:00:00 2001 From: Vasya Novikov Date: Fri, 28 Sep 2018 19:36:53 +0300 Subject: [PATCH 1/4] fix std::thread::sleep typo --- src/libstd/thread/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 3987ae83866e5..ec9f20def7dd0 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -657,7 +657,7 @@ pub fn panicking() -> bool { /// /// # Platform-specific behavior /// -/// On Unix platforms this function will not return early due to a +/// On Unix platforms this function might return early due to a /// signal being received or a spurious wakeup. /// /// # Examples From 049ccbb174552bac2f19df5361c3470828bf04c4 Mon Sep 17 00:00:00 2001 From: Vasya Novikov Date: Fri, 28 Sep 2018 22:40:20 +0300 Subject: [PATCH 2/4] update wording for std::thread::sleep --- src/libstd/thread/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index ec9f20def7dd0..96ce38d12e196 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -650,15 +650,15 @@ pub fn panicking() -> bool { panicking::panicking() } -/// Puts the current thread to sleep for the specified amount of time. +/// Puts the current thread to sleep for at least the specified amount of time. /// /// The thread may sleep longer than the duration specified due to scheduling -/// specifics or platform-dependent functionality. +/// specifics or platform-dependent functionality. It will never sleep less. /// /// # Platform-specific behavior /// -/// On Unix platforms this function might return early due to a -/// signal being received or a spurious wakeup. +/// On Unix platforms this function may invoke multiple syscalls +/// in case of a signal being received or a spurious wakeup. /// /// # Examples /// From b63517a2c3bade20ebfbbd328b11ecf9a1558bd2 Mon Sep 17 00:00:00 2001 From: Vasya Novikov Date: Mon, 1 Oct 2018 11:01:15 +0300 Subject: [PATCH 3/4] update wording for thread::sleep --- src/libstd/thread/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 96ce38d12e196..70a9532665805 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -674,17 +674,17 @@ pub fn sleep_ms(ms: u32) { sleep(Duration::from_millis(ms as u64)) } -/// Puts the current thread to sleep for the specified amount of time. +/// Puts the current thread to sleep for at least the specified amount of time. /// /// The thread may sleep longer than the duration specified due to scheduling -/// specifics or platform-dependent functionality. +/// specifics or platform-dependent functionality. It will never sleep less. /// /// # Platform-specific behavior /// -/// On Unix platforms this function will not return early due to a -/// signal being received or a spurious wakeup. Platforms which do not support -/// nanosecond precision for sleeping will have `dur` rounded up to the nearest -/// granularity of time they can sleep for. +/// On Unix platforms this function may invoke multiple syscalls +/// in case of a signal being received or a spurious wakeup. +/// Platforms which do not support nanosecond precision for sleeping will +/// have `dur` rounded up to the nearest granularity of time they can sleep for. /// /// # Examples /// From 7a0fa95336439120d89bb2f6116146011fd40307 Mon Sep 17 00:00:00 2001 From: Vasya Novikov Date: Thu, 11 Oct 2018 21:37:30 +0300 Subject: [PATCH 4/4] improve docs on thread::sleep --- src/libstd/thread/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 70a9532665805..3f29a81f25e6b 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -657,8 +657,10 @@ pub fn panicking() -> bool { /// /// # Platform-specific behavior /// -/// On Unix platforms this function may invoke multiple syscalls -/// in case of a signal being received or a spurious wakeup. +/// On Unix platforms, the underlying syscall may be interrupted by a +/// spurious wakeup or signal handler. To ensure the sleep occurs for at least +/// the specified duration, this function may invoke that system call multiple +/// times. /// /// # Examples /// @@ -681,8 +683,10 @@ pub fn sleep_ms(ms: u32) { /// /// # Platform-specific behavior /// -/// On Unix platforms this function may invoke multiple syscalls -/// in case of a signal being received or a spurious wakeup. +/// On Unix platforms, the underlying syscall may be interrupted by a +/// spurious wakeup or signal handler. To ensure the sleep occurs for at least +/// the specified duration, this function may invoke that system call multiple +/// times. /// Platforms which do not support nanosecond precision for sleeping will /// have `dur` rounded up to the nearest granularity of time they can sleep for. ///