pub struct RwLockUpgradableReadGuard<'a, T> where
T: ?Sized, { /* private fields */ }Expand description
A guard that releases the upgradable read lock when dropped.
Implementations
impl<'a, T> RwLockUpgradableReadGuard<'a, T> where
T: ?Sized,
impl<'a, T> RwLockUpgradableReadGuard<'a, T> where
T: ?Sized,
pub fn downgrade(
guard: RwLockUpgradableReadGuard<'a, T>
) -> RwLockReadGuard<'a, T>
pub fn downgrade(
guard: RwLockUpgradableReadGuard<'a, T>
) -> RwLockReadGuard<'a, T>
Downgrades into a regular reader guard.
Examples
use async_lock::{RwLock, RwLockUpgradableReadGuard};
let lock = RwLock::new(1);
let reader = lock.upgradable_read().await;
assert_eq!(*reader, 1);
assert!(lock.try_upgradable_read().is_none());
let reader = RwLockUpgradableReadGuard::downgrade(reader);
assert!(lock.try_upgradable_read().is_some());pub fn try_upgrade(
guard: RwLockUpgradableReadGuard<'a, T>
) -> Result<RwLockWriteGuard<'a, T>, RwLockUpgradableReadGuard<'a, T>>
pub fn try_upgrade(
guard: RwLockUpgradableReadGuard<'a, T>
) -> Result<RwLockWriteGuard<'a, T>, RwLockUpgradableReadGuard<'a, T>>
Attempts to upgrade into a write lock.
If a write lock could not be acquired at this time, then None is returned. Otherwise,
an upgraded guard is returned that releases the write lock when dropped.
This function can only fail if there are other active read locks.
Examples
use async_lock::{RwLock, RwLockUpgradableReadGuard};
let lock = RwLock::new(1);
let reader = lock.upgradable_read().await;
assert_eq!(*reader, 1);
let reader2 = lock.read().await;
let reader = RwLockUpgradableReadGuard::try_upgrade(reader).unwrap_err();
drop(reader2);
let writer = RwLockUpgradableReadGuard::try_upgrade(reader).unwrap();pub async fn upgrade(
guard: RwLockUpgradableReadGuard<'a, T>
) -> RwLockWriteGuard<'a, T>
pub async fn upgrade(
guard: RwLockUpgradableReadGuard<'a, T>
) -> RwLockWriteGuard<'a, T>
Upgrades into a write lock.
Examples
use async_lock::{RwLock, RwLockUpgradableReadGuard};
let lock = RwLock::new(1);
let reader = lock.upgradable_read().await;
assert_eq!(*reader, 1);
let mut writer = RwLockUpgradableReadGuard::upgrade(reader).await;
*writer = 2;Trait Implementations
impl<T> Debug for RwLockUpgradableReadGuard<'_, T> where
T: Debug + ?Sized,
impl<T> Debug for RwLockUpgradableReadGuard<'_, T> where
T: Debug + ?Sized,
impl<T> Deref for RwLockUpgradableReadGuard<'_, T> where
T: ?Sized,
impl<T> Deref for RwLockUpgradableReadGuard<'_, T> where
T: ?Sized,
impl<T> Display for RwLockUpgradableReadGuard<'_, T> where
T: Display + ?Sized,
impl<T> Display for RwLockUpgradableReadGuard<'_, T> where
T: Display + ?Sized,
impl<T> Send for RwLockUpgradableReadGuard<'_, T> where
T: Send + Sync + ?Sized,
impl<T> Sync for RwLockUpgradableReadGuard<'_, T> where
T: Sync + ?Sized,
Auto Trait Implementations
impl<'a, T> !RefUnwindSafe for RwLockUpgradableReadGuard<'a, T>
impl<'a, T: ?Sized> Unpin for RwLockUpgradableReadGuard<'a, T>
impl<'a, T> !UnwindSafe for RwLockUpgradableReadGuard<'a, T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output; where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output; where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more