/// returns, regardless of whether the timeout elapsed or not.
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.6.0", reason = "replaced by `std::sync::Condvar::wait_timeout`")]
- #[allow(deprecated)]
pub fn wait_timeout_ms<'a, T>(&self, guard: MutexGuard<'a, T>, ms: u32)
-> LockResult<(MutexGuard<'a, T>, bool)> {
- unsafe {
- let me: &'static Condvar = &*(self as *const _);
- me.inner.wait_timeout_ms(guard, ms)
- }
+ let res = self.wait_timeout(guard, Duration::from_millis(ms as u64));
+ poison::map_result(res, |(a, b)| {
+ (a, !b.timed_out())
+ })
}
/// Waits on this condition variable for a notification, timing out after a
}
}
- /// Waits on this condition variable for a notification, timing out after a
- /// specified duration.
- ///
- /// The semantics of this function are equivalent to `wait_timeout` except
- /// that the implementation will repeatedly wait while the duration has not
- /// passed and the provided function returns `false`.
- #[unstable(feature = "wait_timeout_with",
- reason = "unsure if this API is broadly needed or what form it should take",
- issue = "27748")]
- #[rustc_deprecated(since = "1.8.0",
- reason = "wonky signature and questionable \
- implementation didn't justify existence")]
- pub fn wait_timeout_with<'a, T, F>(&self,
- guard: MutexGuard<'a, T>,
- dur: Duration,
- f: F)
- -> LockResult<(MutexGuard<'a, T>, WaitTimeoutResult)>
- where F: FnMut(LockResult<&mut T>) -> bool {
- unsafe {
- let me: &'static Condvar = &*(self as *const _);
- me.inner.wait_timeout_with(guard, dur, f)
- }
- }
-
/// Wakes up one blocked thread on this condvar.
///
/// If there is a blocked thread on this condition variable, then it will
}
}
- /// Waits on this condition variable for a notification, timing out after a
- /// specified duration.
- ///
- /// See `Condvar::wait_timeout`.
- #[unstable(feature = "static_condvar",
- reason = "may be merged with Condvar in the future",
- issue = "27717")]
- #[rustc_deprecated(since = "1.6.0",
- reason = "replaced by `std::sync::StaticCondvar::wait_timeout`")]
- pub fn wait_timeout_ms<'a, T>(&'static self, guard: MutexGuard<'a, T>, ms: u32)
- -> LockResult<(MutexGuard<'a, T>, bool)> {
- match self.wait_timeout(guard, Duration::from_millis(ms as u64)) {
- Ok((guard, timed_out)) => Ok((guard, !timed_out.timed_out())),
- Err(poison) => {
- let (guard, timed_out) = poison.into_inner();
- Err(PoisonError::new((guard, !timed_out.timed_out())))
- }
- }
- }
-
/// Waits on this condition variable for a notification, timing out after a
/// specified duration.
///