pub struct RwLock<T: ?Sized> { /* private fields */ }Expand description
An async reader-writer lock: .read().await/.write().await yield
the calling task rather than blocking the OS thread while contended.
Implementations§
Source§impl<T> RwLock<T>
impl<T> RwLock<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the lock, returning the guarded value.
Source§impl<T: ?Sized + Send + Sync> RwLock<T>
impl<T: ?Sized + Send + Sync> RwLock<T>
Sourcepub async fn read(&self) -> RwLockReadGuard<'_, T>
pub async fn read(&self) -> RwLockReadGuard<'_, T>
Acquire a shared read lock, waiting while a writer holds it. Multiple readers may hold the lock concurrently.
Sourcepub async fn write(&self) -> RwLockWriteGuard<'_, T>
pub async fn write(&self) -> RwLockWriteGuard<'_, T>
Acquire the exclusive write lock, waiting while any reader or writer holds it.
Trait Implementations§
impl<T: ?Sized + Send> Send for RwLock<T>
impl<T: ?Sized + Send + Sync> Sync for RwLock<T>
Auto Trait Implementations§
impl<T> !Freeze for RwLock<T>
impl<T> !RefUnwindSafe for RwLock<T>
impl<T> Unpin for RwLock<T>
impl<T> UnsafeUnpin for RwLock<T>where
T: UnsafeUnpin + ?Sized,
impl<T> UnwindSafe for RwLock<T>where
T: UnwindSafe + ?Sized,
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