Struct mutex_timeouts::std::MutexWithTimeout
source · pub struct MutexWithTimeout<T> { /* private fields */ }Expand description
A wrapper around std::sync::Mutex that allows for a timeout to be set.
Implementations§
source§impl<T> MutexWithTimeout<T>
impl<T> MutexWithTimeout<T>
sourcepub fn new(inner: T, timeout: Duration) -> Self
pub fn new(inner: T, timeout: Duration) -> Self
Creates a new MutexWithTimeout with the given timeout.
sourcepub fn lock(&self) -> Option<MutexGuard<'_, T>>
pub fn lock(&self) -> Option<MutexGuard<'_, T>>
Will attempt to lock the inner std::sync::Mutex.
If the lock is not acquired within the timeout, None will be returned.
sourcepub fn try_lock(&self) -> Option<MutexGuard<'_, T>>
pub fn try_lock(&self) -> Option<MutexGuard<'_, T>>
Calls the inner mutex’s try_lock method.