pub struct TryRwLock<T> { /* private fields */ }
Expand description
A readers-writer lock.
Implementations§
Source§impl<T> TryRwLock<T>
impl<T> TryRwLock<T>
Sourcepub fn try_read(&self) -> Option<ReadGuard<'_, T>>
pub fn try_read(&self) -> Option<ReadGuard<'_, T>>
Attempt to lock this TryRwLock
with shared read access.
If the lock is currently being written to or there are usize::MAX
existing readers, this
function will return None
.
Sourcepub fn try_write(&self) -> Option<WriteGuard<'_, T>>
pub fn try_write(&self) -> Option<WriteGuard<'_, T>>
Attempt to lock this TryRwLock
with unique write access.
If the lock is currently being written to or read from, this function will return None
.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Get the underlying data of the lock.
Sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Get a mutable reference to the underlying data.
As this method takes a mutable reference, no locking needs to take place.
Sourcepub fn is_write_locked(&self) -> bool
pub fn is_write_locked(&self) -> bool
Check if the lock is currently locked for writing, or if there are usize::MAX
readers.
Trait Implementations§
impl<T: Send> Send for TryRwLock<T>
impl<T: Send + Sync> Sync for TryRwLock<T>
Auto Trait Implementations§
impl<T> !Freeze for TryRwLock<T>
impl<T> !RefUnwindSafe for TryRwLock<T>
impl<T> Unpin for TryRwLock<T>where
T: Unpin,
impl<T> UnwindSafe for TryRwLock<T>where
T: UnwindSafe,
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