pub struct CondVar { /* private fields */ }Implementations§
Source§impl CondVar
impl CondVar
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new condition variable via heap allocation (only in heap mode).
Sourcepub fn create(storage: &'static CondVarStorage) -> Result<Self>
pub fn create(storage: &'static CondVarStorage) -> Result<Self>
Mode-agnostic constructor (see Mutex::create).
Sourcepub fn wait<'a, T: ?Sized>(
&self,
guard: MutexGuard<'a, T>,
) -> Result<MutexGuard<'a, T>>
pub fn wait<'a, T: ?Sized>( &self, guard: MutexGuard<'a, T>, ) -> Result<MutexGuard<'a, T>>
Atomically release the guarded mutex and block indefinitely
until signalled. On return, the mutex is re-acquired and the
guard handed back. std::sync::Condvar::wait analog.
Always re-check the predicate in a loop after this returns —
spurious wake-ups are permitted by the substrate. Or use
wait_while which does the loop for you.
Sourcepub fn wait_for<'a, T: ?Sized>(
&self,
guard: MutexGuard<'a, T>,
d: Duration,
) -> Result<(MutexGuard<'a, T>, WaitTimeoutResult)>
pub fn wait_for<'a, T: ?Sized>( &self, guard: MutexGuard<'a, T>, d: Duration, ) -> Result<(MutexGuard<'a, T>, WaitTimeoutResult)>
Atomically release the guarded mutex and wait up to d. On
return, the mutex is re-acquired. parking_lot::Condvar::wait_for
analog.
The returned WaitTimeoutResult distinguishes “signalled in
time” (timed_out() == false) from “elapsed without signal”
(timed_out() == true).
§Errors
Returns an error for backend failures other than a clean timeout
— a clean timeout returns Ok((guard, WaitTimeoutResult { ..true })).
Sourcepub fn wait_until<'a, T: ?Sized>(
&self,
guard: MutexGuard<'a, T>,
deadline: Instant,
) -> Result<(MutexGuard<'a, T>, WaitTimeoutResult)>
pub fn wait_until<'a, T: ?Sized>( &self, guard: MutexGuard<'a, T>, deadline: Instant, ) -> Result<(MutexGuard<'a, T>, WaitTimeoutResult)>
Atomically release the guarded mutex and wait by the given
deadline. parking_lot::Condvar::wait_until analog. Use
Instant::FOREVER for an
indefinite wait.
Sourcepub fn wait_while<'a, T: ?Sized, F>(
&self,
guard: MutexGuard<'a, T>,
cond: F,
) -> Result<MutexGuard<'a, T>>
pub fn wait_while<'a, T: ?Sized, F>( &self, guard: MutexGuard<'a, T>, cond: F, ) -> Result<MutexGuard<'a, T>>
Loop until cond(&mut T) returns false, releasing the lock
while waiting. std::sync::Condvar::wait_while analog.
Internally handles spurious wake-ups by re-checking the predicate after every wake.
Sourcepub fn wait_while_for<'a, T: ?Sized, F>(
&self,
guard: MutexGuard<'a, T>,
d: Duration,
cond: F,
) -> Result<(MutexGuard<'a, T>, WaitTimeoutResult)>
pub fn wait_while_for<'a, T: ?Sized, F>( &self, guard: MutexGuard<'a, T>, d: Duration, cond: F, ) -> Result<(MutexGuard<'a, T>, WaitTimeoutResult)>
wait_while with a duration bound.
Returns (guard, WaitTimeoutResult) — timed_out() is true
iff the predicate is still true at deadline.
Sourcepub fn wait_while_until<'a, T: ?Sized, F>(
&self,
guard: MutexGuard<'a, T>,
deadline: Instant,
cond: F,
) -> Result<(MutexGuard<'a, T>, WaitTimeoutResult)>
pub fn wait_while_until<'a, T: ?Sized, F>( &self, guard: MutexGuard<'a, T>, deadline: Instant, cond: F, ) -> Result<(MutexGuard<'a, T>, WaitTimeoutResult)>
wait_while with an absolute deadline.