pub enum WaitTimeoutStatus {
Woken,
TimedOut,
}Expand description
Result of a timed wait operation.
This status is returned by
ParkingLotMonitorGuard::wait_timeout and
ParkingLotMonitor::wait_for. It describes why a
timed wait returned, but callers must still re-check the protected state
because condition variables may wake spuriously.
§Example
use std::time::Duration;
use qubit_lock::{ParkingLotMonitor, WaitTimeoutStatus};
let monitor = ParkingLotMonitor::new(false);
let guard = monitor.lock();
let (_guard, status) = guard.wait_timeout(Duration::from_millis(1));
assert_eq!(status, WaitTimeoutStatus::TimedOut);Variants§
Woken
The wait returned before the timeout elapsed.
This usually means another thread called
ParkingLotMonitor::notify_one or
ParkingLotMonitor::notify_all, but it may also be
a spurious wakeup. Always re-check the guarded state before acting on
this status.
TimedOut
The wait reached the timeout boundary.
Even after this status, callers should inspect the protected state because another thread may have changed it while the waiting thread was reacquiring the mutex.
Implementations§
Source§impl WaitTimeoutStatus
impl WaitTimeoutStatus
Sourcepub const fn is_woken(&self) -> bool
pub const fn is_woken(&self) -> bool
Returns true when the wait returned before the timeout elapsed.
§Returns
true for Self::Woken, otherwise false.
Sourcepub const fn is_timed_out(&self) -> bool
pub const fn is_timed_out(&self) -> bool
Returns true when the wait reached the timeout boundary.
§Returns
true for Self::TimedOut, otherwise false.
Trait Implementations§
Source§impl Clone for WaitTimeoutStatus
impl Clone for WaitTimeoutStatus
Source§fn clone(&self) -> WaitTimeoutStatus
fn clone(&self) -> WaitTimeoutStatus
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WaitTimeoutStatus
impl Debug for WaitTimeoutStatus
Source§impl PartialEq for WaitTimeoutStatus
impl PartialEq for WaitTimeoutStatus
Source§fn eq(&self, other: &WaitTimeoutStatus) -> bool
fn eq(&self, other: &WaitTimeoutStatus) -> bool
self and other values to be equal, and is used by ==.