diff options
| author | bors <bors@rust-lang.org> | 2016-08-05 07:37:16 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-05 07:37:16 -0700 |
| commit | b30eff7ba72a78e31acd61a2b6931919a0ad62e8 (patch) | |
| tree | 7261c377c72620cd6cd3d668cdbb7a7236469d58 /src/libstd/thread | |
| parent | 4c02363852e6ce41cf2da1b43a32cb7780a9b067 (diff) | |
| parent | cd48161e2ca866ef05a076181225cb041c679994 (diff) | |
| download | rust-b30eff7ba72a78e31acd61a2b6931919a0ad62e8.tar.gz rust-b30eff7ba72a78e31acd61a2b6931919a0ad62e8.zip | |
Auto merge of #35365 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 30 pull requests - Successful merges: #34319, #35041, #35042, #35076, #35109, #35137, #35175, #35181, #35182, #35189, #35239, #35264, #35266, #35281, #35285, #35289, #35291, #35294, #35296, #35297, #35298, #35299, #35318, #35319, #35324, #35326, #35328, #35333, #35359, #35362 - Failed merges:
Diffstat (limited to 'src/libstd/thread')
| -rw-r--r-- | src/libstd/thread/mod.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index e9736fea7b3..f06c105d30e 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -447,6 +447,8 @@ pub fn park() { *guard = false; } +/// Use [park_timeout]. +/// /// Blocks unless or until the current thread's token is made available or /// the specified duration has been reached (may wake spuriously). /// @@ -456,7 +458,10 @@ pub fn park() { /// preemption or platform differences that may not cause the maximum /// amount of time waited to be precisely `ms` long. /// -/// See the module doc for more detail. +/// See the [module documentation][thread] for more detail. +/// +/// [thread]: index.html +/// [park_timeout]: fn.park_timeout.html #[stable(feature = "rust1", since = "1.0.0")] #[rustc_deprecated(since = "1.6.0", reason = "replaced by `std::thread::park_timeout`")] pub fn park_timeout_ms(ms: u32) { @@ -478,6 +483,25 @@ pub fn park_timeout_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. +/// +/// # Example +/// +/// Waiting for the complete expiration of the timeout: +/// +/// ```rust,no_run +/// use std::thread::park_timeout; +/// use std::time::{Instant, Duration}; +/// +/// let timeout = Duration::from_secs(2); +/// let beginning_park = Instant::now(); +/// park_timeout(timeout); +/// +/// while beginning_park.elapsed() < timeout { +/// println!("restarting park_timeout after {:?}", beginning_park.elapsed()); +/// let timeout = timeout - beginning_park.elapsed(); +/// park_timeout(timeout); +/// } +/// ``` #[stable(feature = "park_timeout", since = "1.4.0")] pub fn park_timeout(dur: Duration) { let thread = current(); |
