Struct async_lock::RwLockWriteGuardArc
source · pub struct RwLockWriteGuardArc<T: ?Sized> { /* private fields */ }
Expand description
An owned, reference-counted guard that releases the write lock when dropped.
Implementations§
source§impl<T> RwLockWriteGuardArc<T>
impl<T> RwLockWriteGuardArc<T>
sourcepub fn downgrade(guard: Self) -> RwLockReadGuardArc<T>
pub fn downgrade(guard: Self) -> RwLockReadGuardArc<T>
Downgrades into a regular reader guard.
Examples
use std::sync::Arc;
use async_lock::{RwLock, RwLockWriteGuardArc};
let lock = Arc::new(RwLock::new(1));
let mut writer = lock.write_arc().await;
*writer += 1;
assert!(lock.try_read_arc().is_none());
let reader = RwLockWriteGuardArc::downgrade(writer);
assert_eq!(*reader, 2);
assert!(lock.try_read_arc().is_some());
source§impl<T: ?Sized> RwLockWriteGuardArc<T>
impl<T: ?Sized> RwLockWriteGuardArc<T>
sourcepub fn downgrade_to_upgradable(guard: Self) -> RwLockUpgradableReadGuardArc<T>
pub fn downgrade_to_upgradable(guard: Self) -> RwLockUpgradableReadGuardArc<T>
Downgrades into an upgradable reader guard.
Examples
use std::sync::Arc;
use async_lock::{RwLock, RwLockUpgradableReadGuardArc, RwLockWriteGuardArc};
let lock = Arc::new(RwLock::new(1));
let mut writer = lock.write_arc().await;
*writer += 1;
assert!(lock.try_read_arc().is_none());
let reader = RwLockWriteGuardArc::downgrade_to_upgradable(writer);
assert_eq!(*reader, 2);
assert!(lock.try_write_arc().is_none());
assert!(lock.try_read_arc().is_some());
assert!(RwLockUpgradableReadGuardArc::try_upgrade(reader).is_ok())
Trait Implementations§
source§impl<T: ?Sized> Deref for RwLockWriteGuardArc<T>
impl<T: ?Sized> Deref for RwLockWriteGuardArc<T>
source§impl<T: ?Sized> DerefMut for RwLockWriteGuardArc<T>
impl<T: ?Sized> DerefMut for RwLockWriteGuardArc<T>
source§impl<T: ?Sized> Drop for RwLockWriteGuardArc<T>
impl<T: ?Sized> Drop for RwLockWriteGuardArc<T>
impl<T: Send + Sync + ?Sized> Send for RwLockWriteGuardArc<T>
impl<T: Send + Sync + ?Sized> Sync for RwLockWriteGuardArc<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for RwLockWriteGuardArc<T>
impl<T: ?Sized> Unpin for RwLockWriteGuardArc<T>
impl<T> !UnwindSafe for RwLockWriteGuardArc<T>
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