Struct mycelium_util::sync::blocking::MutexGuard
source · pub struct MutexGuard<'a, T, Lock>where
Lock: RawMutex,{ /* private fields */ }Expand description
An RAII implementation of a “scoped lock” of a mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.
The data protected by the mutex can be accessed through this guard via its
Deref and DerefMut implementations.
This structure is created by the lock and try_lock methods on
Mutex.
Trait Implementations§
source§impl<T, Lock, R> AsMut<R> for MutexGuard<'_, T, Lock>
impl<T, Lock, R> AsMut<R> for MutexGuard<'_, T, Lock>
source§impl<T, Lock, R> AsRef<R> for MutexGuard<'_, T, Lock>
impl<T, Lock, R> AsRef<R> for MutexGuard<'_, T, Lock>
source§impl<T, Lock> Debug for MutexGuard<'_, T, Lock>
impl<T, Lock> Debug for MutexGuard<'_, T, Lock>
source§impl<T, Lock> Deref for MutexGuard<'_, T, Lock>where
Lock: RawMutex,
impl<T, Lock> Deref for MutexGuard<'_, T, Lock>where
Lock: RawMutex,
source§impl<T, Lock> DerefMut for MutexGuard<'_, T, Lock>where
Lock: RawMutex,
impl<T, Lock> DerefMut for MutexGuard<'_, T, Lock>where
Lock: RawMutex,
source§impl<T, Lock> Display for MutexGuard<'_, T, Lock>
impl<T, Lock> Display for MutexGuard<'_, T, Lock>
source§impl<T, Lock> Drop for MutexGuard<'_, T, Lock>where
Lock: RawMutex,
impl<T, Lock> Drop for MutexGuard<'_, T, Lock>where
Lock: RawMutex,
impl<T, Lock> Send for MutexGuard<'_, T, Lock>
A MutexGuard is only Send if:
- the protected data (
T) isSend, because the guard may be used to mutably access the protected data, and can therefore be used to move it usingcore::mem::replaceor similar. - the
Locktype parameter isSync, because the guard contains a reference to theLocktype, and therefore, sending the guard is sharing a reference to theLock. - the
Locktype’sRawMutex::GuardMarkerassociated type isSend, because this indicates that theLocktype agrees that guards may beSend.
Auto Trait Implementations§
impl<'a, T, Lock> Freeze for MutexGuard<'a, T, Lock>
impl<'a, T, Lock> RefUnwindSafe for MutexGuard<'a, T, Lock>
impl<'a, T, Lock> !Sync for MutexGuard<'a, T, Lock>
impl<'a, T, Lock> Unpin for MutexGuard<'a, T, Lock>
impl<'a, T, Lock> UnwindSafe for MutexGuard<'a, T, Lock>
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