pub struct Condvar {}
+pub struct WaitTimeoutResult(bool);
+impl WaitTimeoutResult {
+ pub fn timed_out(&self) -> bool { self.0 }
+}
+
impl Condvar {
pub fn new() -> Condvar {
Condvar { }
Ok((guard, ()))
}
+ pub fn wait_while<'a, T, F: FnMut(&mut T) -> bool>(&'a self, mut guard: MutexGuard<'a, T>, mut condition: F)
+ -> LockResult<MutexGuard<'a, T>> {
+ assert!(!condition(&mut *guard));
+ Ok(guard)
+ }
+
+ #[allow(unused)]
+ pub fn wait_timeout_while<'a, T, F: FnMut(&mut T) -> bool>(&'a self, mut guard: MutexGuard<'a, T>, dur: Duration, mut condition: F)
+ -> LockResult<(MutexGuard<'a, T>, WaitTimeoutResult)> {
+ if condition(&mut *guard) {
+ Ok((guard, WaitTimeoutResult(true)))
+ } else {
+ Ok((guard, WaitTimeoutResult(false)))
+ }
+ }
+
pub fn notify_all(&self) {}
}
pub fn try_lock<'a>(&'a self) -> LockResult<MutexGuard<'a, T>> {
Ok(MutexGuard { lock: self.inner.borrow_mut() })
}
+
+ pub fn into_inner(self) -> LockResult<T> {
+ Ok(self.inner.into_inner())
+ }
}
impl<'a, T: 'a> LockTestExt<'a> for Mutex<T> {