pub struct MutexGuard<'a, T: ?Sized> { /* private fields */ }Expand description
RAII guard that unlocks a Mutex<T> when dropped.
Deref / DerefMut expose the protected value. MutexGuard is
!Send: the locking thread must release the lock. Sending a guard
to another thread would cause that thread to issue
ove_mutex_unlock with no matching ove_mutex_lock, which is
backend-defined UB. The _no_send field carries a GuardNoSend
PhantomData to propagate !Send at compile time (the same trick
lock_api / parking_lot use on stable Rust).
Sync is reinstated for T: Sync — a &MutexGuard<T> is the same
as a &T, which is Send if T: Sync. Matches std and
parking_lot.
Trait Implementations§
Source§impl<T: ?Sized> Deref for MutexGuard<'_, T>
impl<T: ?Sized> Deref for MutexGuard<'_, T>
Source§impl<T: ?Sized> DerefMut for MutexGuard<'_, T>
impl<T: ?Sized> DerefMut for MutexGuard<'_, T>
Source§impl<T: ?Sized> Drop for MutexGuard<'_, T>
impl<T: ?Sized> Drop for MutexGuard<'_, T>
impl<T: ?Sized + Sync> Sync for MutexGuard<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for MutexGuard<'a, T>where
T: ?Sized,
impl<'a, T> !RefUnwindSafe for MutexGuard<'a, T>
impl<'a, T> !Send for MutexGuard<'a, T>
impl<'a, T> Unpin for MutexGuard<'a, T>where
T: ?Sized,
impl<'a, T> UnsafeUnpin for MutexGuard<'a, T>where
T: ?Sized,
impl<'a, T> !UnwindSafe for MutexGuard<'a, T>
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