diff options
| author | kennytm <kennytm@gmail.com> | 2018-10-18 10:47:17 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-10-18 12:54:42 +0800 |
| commit | e4ac4478514779d956cbc51068ec2d3207083bfa (patch) | |
| tree | 516ab13f623c2d95d49aab96f852ea6b7dbd870c /src/libstd/thread | |
| parent | f7eb7fbbf6bca0eaa146c4a48cd39c133a257706 (diff) | |
| parent | 7a0fa95336439120d89bb2f6116146011fd40307 (diff) | |
| download | rust-e4ac4478514779d956cbc51068ec2d3207083bfa.tar.gz rust-e4ac4478514779d956cbc51068ec2d3207083bfa.zip | |
Rollup merge of #54646 - vn971:fix_std_thread_sleep, r=frewsxcv
improve documentation on std::thread::sleep
Diffstat (limited to 'src/libstd/thread')
| -rw-r--r-- | src/libstd/thread/mod.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 796b2bd3eed..c1f0a6fecef 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -650,15 +650,17 @@ 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 will not return early due to 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 /// @@ -674,17 +676,19 @@ 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, 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. /// /// # Examples /// |
