Struct maitake::sync::blocking::MutexGuard
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§
§impl<T, Lock, R> AsMut<R> for MutexGuard<'_, T, Lock>
impl<T, Lock, R> AsMut<R> for MutexGuard<'_, T, Lock>
§impl<T, Lock, R> AsRef<R> for MutexGuard<'_, T, Lock>
impl<T, Lock, R> AsRef<R> for MutexGuard<'_, T, Lock>
§impl<T, Lock> Debug for MutexGuard<'_, T, Lock>
impl<T, Lock> Debug for MutexGuard<'_, T, Lock>
§impl<T, Lock> Deref for MutexGuard<'_, T, Lock>where
Lock: RawMutex,
impl<T, Lock> Deref for MutexGuard<'_, T, Lock>where
Lock: RawMutex,
§impl<T, Lock> DerefMut for MutexGuard<'_, T, Lock>where
Lock: RawMutex,
impl<T, Lock> DerefMut for MutexGuard<'_, T, Lock>where
Lock: RawMutex,
§fn deref_mut(&mut self) -> &mut <MutexGuard<'_, T, Lock> as Deref>::Target
fn deref_mut(&mut self) -> &mut <MutexGuard<'_, T, Lock> as Deref>::Target
Mutably dereferences the value.
§impl<T, Lock> Display for MutexGuard<'_, T, Lock>
impl<T, Lock> Display for MutexGuard<'_, T, Lock>
§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::replace
or similar. - the
Lock
type parameter isSync
, because the guard contains a reference to theLock
type, and therefore, sending the guard is sharing a reference to theLock
. - the
Lock
type’sRawMutex::GuardMarker
associated type isSend
, because this indicates that theLock
type agrees that guards may beSend
.
Auto Trait Implementations§
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