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.
Trait Implementations§
impl<T> RefUnwindSafe for RwLock<T>where
T: ?Sized,
impl<T> Send for RwLock<T>
impl<T> Sync for RwLock<T>
impl<T> UnwindSafe for RwLock<T>where
T: ?Sized,
Auto Trait Implementations§
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