pub struct UpgradableAsyncRwLock<T> { /* private fields */ }Expand description
A Tokio-based async rwlock with an upgradable read mode.
All write and upgradable_read acquisitions take an internal async mutex (“gate”) first.
This ensures that upgrading from read to write does not allow another writer to slip in.
Implementations§
Source§impl<T> UpgradableAsyncRwLock<T>
impl<T> UpgradableAsyncRwLock<T>
Sourcepub async fn read(&self) -> RwLockReadGuard<'_, T>
pub async fn read(&self) -> RwLockReadGuard<'_, T>
Acquire a shared read guard.
Sourcepub async fn write(&self) -> UpgradableAsyncRwLockWriteGuard<'_, T>
pub async fn write(&self) -> UpgradableAsyncRwLockWriteGuard<'_, T>
Acquire an exclusive write guard.
Writers are serialized through the internal gate.
Sourcepub async fn upgradable_read(
&self,
) -> UpgradableAsyncRwLockUpgradableReadGuard<'_, T>
pub async fn upgradable_read( &self, ) -> UpgradableAsyncRwLockUpgradableReadGuard<'_, T>
Acquire an upgradable read guard.
This allows shared reads, then a later UpgradableAsyncRwLockUpgradableReadGuard::upgrade to exclusive write while holding the same gate token.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the lock and return the wrapped value.
Auto Trait Implementations§
impl<T> !Freeze for UpgradableAsyncRwLock<T>
impl<T> !RefUnwindSafe for UpgradableAsyncRwLock<T>
impl<T> Send for UpgradableAsyncRwLock<T>where
T: Send,
impl<T> Sync for UpgradableAsyncRwLock<T>
impl<T> Unpin for UpgradableAsyncRwLock<T>where
T: Unpin,
impl<T> UnsafeUnpin for UpgradableAsyncRwLock<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for UpgradableAsyncRwLock<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