Struct peace_lock::Mutex
source · pub struct Mutex<T: ?Sized> { /* private fields */ }Expand description
A mutual exclusive lock
Implementations§
source§impl<T> Mutex<T>
impl<T> Mutex<T>
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the Mutex, returning the inner value.
source§impl<T> Mutex<T>where
T: ?Sized,
impl<T> Mutex<T>where T: ?Sized,
sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Get a mutable reference of the inner value T. This is safe because we have the mutable reference of the lock.
sourcepub fn try_lock<'a>(&'a self) -> Option<MutexGuard<'a, T>>
pub fn try_lock<'a>(&'a self) -> Option<MutexGuard<'a, T>>
Try lock the Mutex, returns the mutex guard. Returns None if the
Mutex is write locked.
sourcepub fn lock<'a>(&'a self) -> MutexGuard<'a, T>
pub fn lock<'a>(&'a self) -> MutexGuard<'a, T>
Lock the Mutex, returns the mutex guard.
Panics
If the Mutex is already locked, this will panic if the check feature
is turned on.