about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-09-13 18:55:19 -0400
committerGitHub <noreply@github.com>2025-09-13 18:55:19 -0400
commit08db93806b2bb090fc8a8857c62a02aed521e39e (patch)
tree13ffbef4356b9b18a68aa5fc2fdbb4b3d6298785
parent392d2fad16ef36fe894fc2798c37d3aa66a5590f (diff)
parentf21d3fbce96b956283bdda0557fb73604a0fd489 (diff)
downloadrust-08db93806b2bb090fc8a8857c62a02aed521e39e.tar.gz
rust-08db93806b2bb090fc8a8857c62a02aed521e39e.zip
Rollup merge of #146517 - RalfJung:wait-timeout, r=joboet
fix Condvar::wait_timeout docs

[Context](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Condvar.20wait_timeout.20sleep.20duration.20decremented/with/539279839)
r? `@joboet`
-rw-r--r--library/std/src/sync/nonpoison/condvar.rs9
-rw-r--r--library/std/src/sync/poison/condvar.rs9
2 files changed, 8 insertions, 10 deletions
diff --git a/library/std/src/sync/nonpoison/condvar.rs b/library/std/src/sync/nonpoison/condvar.rs
index 49afdd87818..994fc6816a0 100644
--- a/library/std/src/sync/nonpoison/condvar.rs
+++ b/library/std/src/sync/nonpoison/condvar.rs
@@ -198,11 +198,10 @@ impl Condvar {
     /// the system time. This function is susceptible to spurious wakeups.
     /// Condition variables normally have a boolean predicate associated with
     /// them, and the predicate must always be checked each time this function
-    /// returns to protect against spurious wakeups. Additionally, it is
-    /// typically desirable for the timeout to not exceed some duration in
-    /// spite of spurious wakes, thus the sleep-duration is decremented by the
-    /// amount slept. Alternatively, use the `wait_timeout_while` method
-    /// to wait with a timeout while a predicate is true.
+    /// returns to protect against spurious wakeups.  Furthermore, since the timeout
+    /// is given relative to the moment this function is called, it needs to be adjusted
+    /// when this function is called in a loop. The [`wait_timeout_while`] method
+    /// lets you wait with a timeout while a predicate is true, taking care of all these concerns.
     ///
     /// The returned [`WaitTimeoutResult`] value indicates if the timeout is
     /// known to have elapsed.
diff --git a/library/std/src/sync/poison/condvar.rs b/library/std/src/sync/poison/condvar.rs
index 5dc2b510f3a..de625a6cc5f 100644
--- a/library/std/src/sync/poison/condvar.rs
+++ b/library/std/src/sync/poison/condvar.rs
@@ -269,11 +269,10 @@ impl Condvar {
     /// the system time. This function is susceptible to spurious wakeups.
     /// Condition variables normally have a boolean predicate associated with
     /// them, and the predicate must always be checked each time this function
-    /// returns to protect against spurious wakeups. Additionally, it is
-    /// typically desirable for the timeout to not exceed some duration in
-    /// spite of spurious wakes, thus the sleep-duration is decremented by the
-    /// amount slept. Alternatively, use the `wait_timeout_while` method
-    /// to wait with a timeout while a predicate is true.
+    /// returns to protect against spurious wakeups. Furthermore, since the timeout
+    /// is given relative to the moment this function is called, it needs to be adjusted
+    /// when this function is called in a loop. The [`wait_timeout_while`] method
+    /// lets you wait with a timeout while a predicate is true, taking care of all these concerns.
     ///
     /// The returned [`WaitTimeoutResult`] value indicates if the timeout is
     /// known to have elapsed.