Skip to content

Commit 08db938

Browse files
authored
Rollup merge of rust-lang#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`
2 parents 392d2fa + f21d3fb commit 08db938

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

library/std/src/sync/nonpoison/condvar.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,10 @@ impl Condvar {
198198
/// the system time. This function is susceptible to spurious wakeups.
199199
/// Condition variables normally have a boolean predicate associated with
200200
/// them, and the predicate must always be checked each time this function
201-
/// returns to protect against spurious wakeups. Additionally, it is
202-
/// typically desirable for the timeout to not exceed some duration in
203-
/// spite of spurious wakes, thus the sleep-duration is decremented by the
204-
/// amount slept. Alternatively, use the `wait_timeout_while` method
205-
/// to wait with a timeout while a predicate is true.
201+
/// returns to protect against spurious wakeups. Furthermore, since the timeout
202+
/// is given relative to the moment this function is called, it needs to be adjusted
203+
/// when this function is called in a loop. The [`wait_timeout_while`] method
204+
/// lets you wait with a timeout while a predicate is true, taking care of all these concerns.
206205
///
207206
/// The returned [`WaitTimeoutResult`] value indicates if the timeout is
208207
/// known to have elapsed.

library/std/src/sync/poison/condvar.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,10 @@ impl Condvar {
269269
/// the system time. This function is susceptible to spurious wakeups.
270270
/// Condition variables normally have a boolean predicate associated with
271271
/// them, and the predicate must always be checked each time this function
272-
/// returns to protect against spurious wakeups. Additionally, it is
273-
/// typically desirable for the timeout to not exceed some duration in
274-
/// spite of spurious wakes, thus the sleep-duration is decremented by the
275-
/// amount slept. Alternatively, use the `wait_timeout_while` method
276-
/// to wait with a timeout while a predicate is true.
272+
/// returns to protect against spurious wakeups. Furthermore, since the timeout
273+
/// is given relative to the moment this function is called, it needs to be adjusted
274+
/// when this function is called in a loop. The [`wait_timeout_while`] method
275+
/// lets you wait with a timeout while a predicate is true, taking care of all these concerns.
277276
///
278277
/// The returned [`WaitTimeoutResult`] value indicates if the timeout is
279278
/// known to have elapsed.

0 commit comments

Comments
 (0)