Struct closeable_mutex::CloseableMutex
source · pub struct CloseableMutex<T: ?Sized> { /* private fields */ }
Expand description
A mutex that can be closed.
A closed mutex can be accessed freely by the owner, but while closed it cannot be locked by anyone else.
Implementations§
source§impl<T> CloseableMutex<T>
impl<T> CloseableMutex<T>
source§impl<T: ?Sized> CloseableMutex<T>
impl<T: ?Sized> CloseableMutex<T>
sourcepub fn close(self: Arc<Self>) -> ClosedGuard<T>
pub fn close(self: Arc<Self>) -> ClosedGuard<T>
Closes the mutex, returning a guard that can be used to access the underlying value.
When the guard is dropped, the mutex is re-opened.
While the mutex is closed, calls to lock_if_open
will return None
,
and calls to lock
will panic.
sourcepub fn lock_if_open(&self) -> Option<OpenGuard<'_, T>>
pub fn lock_if_open(&self) -> Option<OpenGuard<'_, T>>
If the lock is open, waits for it to become available and returns a guard that can be used to access the underlying value.
If the lock is closed, returns None
.
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for CloseableMutex<T>
impl<T> !RefUnwindSafe for CloseableMutex<T>
impl<T> Send for CloseableMutex<T>
impl<T> Unpin for CloseableMutex<T>
impl<T> UnwindSafe for CloseableMutex<T>where
T: UnwindSafe + ?Sized,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more