summaryrefslogtreecommitdiffstats
path: root/library/std/src/sync/condvar.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /library/std/src/sync/condvar.rs
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/std/src/sync/condvar.rs')
-rw-r--r--library/std/src/sync/condvar.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/library/std/src/sync/condvar.rs b/library/std/src/sync/condvar.rs
index 76a1b4a2a..9c4b926b7 100644
--- a/library/std/src/sync/condvar.rs
+++ b/library/std/src/sync/condvar.rs
@@ -21,11 +21,11 @@ impl WaitTimeoutResult {
///
/// # Examples
///
- /// This example spawns a thread which will update the boolean value and
- /// then wait 100 milliseconds before notifying the condvar.
+ /// This example spawns a thread which will sleep 20 milliseconds before
+ /// updating a boolean value and then notifying the condvar.
///
- /// The main thread will wait with a timeout on the condvar and then leave
- /// once the boolean has been updated and notified.
+ /// The main thread will wait with a 10 millisecond timeout on the condvar
+ /// and will leave the loop upon timeout.
///
/// ```
/// use std::sync::{Arc, Condvar, Mutex};
@@ -49,14 +49,12 @@ impl WaitTimeoutResult {
///
/// // Wait for the thread to start up.
/// let (lock, cvar) = &*pair;
- /// let mut started = lock.lock().unwrap();
/// loop {
/// // Let's put a timeout on the condvar's wait.
- /// let result = cvar.wait_timeout(started, Duration::from_millis(10)).unwrap();
- /// // 10 milliseconds have passed, or maybe the value changed!
- /// started = result.0;
- /// if *started == true {
- /// // We received the notification and the value has been updated, we can leave.
+ /// let result = cvar.wait_timeout(lock.lock().unwrap(), Duration::from_millis(10)).unwrap();
+ /// // 10 milliseconds have passed.
+ /// if result.1.timed_out() {
+ /// // timed out now and we can leave.
/// break
/// }
/// }