Struct peace_lock::RwLock
source · pub struct RwLock<T: ?Sized> { /* private fields */ }Expand description
A read-write lock
Implementations§
source§impl<T> RwLock<T>
impl<T> RwLock<T>
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the RwLock, returning the inner value.
source§impl<T> RwLock<T>where
T: ?Sized,
impl<T> RwLock<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_write<'a>(&'a self) -> Option<RwLockWriteGuard<'a, T>>
pub fn try_write<'a>(&'a self) -> Option<RwLockWriteGuard<'a, T>>
Try write lock the RwLock, returns the write guard. Returns None if the
RwLock is write locked.
sourcepub fn write<'a>(&'a self) -> RwLockWriteGuard<'a, T>
pub fn write<'a>(&'a self) -> RwLockWriteGuard<'a, T>
Write lock the RwLock, returns the write guard.
Panics
If the RwLock is already write locked, this will panic if the check
feature is turned on.
sourcepub fn try_read<'a>(&'a self) -> Option<RwLockReadGuard<'a, T>>
pub fn try_read<'a>(&'a self) -> Option<RwLockReadGuard<'a, T>>
Try read lock the RwLock, returns the read guard. Returns None if the
RwLock is write locked.
sourcepub fn read<'a>(&'a self) -> RwLockReadGuard<'a, T>
pub fn read<'a>(&'a self) -> RwLockReadGuard<'a, T>
Read lock the RwLock, returns the read guard.
Panics
If the RwLock is already write locked, this will panic if the check feature
is turned on.