pub struct RwMutexUpgradeableGuard<'a, T> { /* private fields */ }Expand description
A guard that provides immutable data access but can be atomically
upgraded to RwMutexWriteGuard.
Implementations§
Source§impl<'a, T> RwMutexUpgradeableGuard<'a, T>
impl<'a, T> RwMutexUpgradeableGuard<'a, T>
Source§impl<'a, T> RwMutexUpgradeableGuard<'a, T>
impl<'a, T> RwMutexUpgradeableGuard<'a, T>
Sourcepub exec fn upgrade(self) -> RwMutexWriteGuard<'a, T>
pub exec fn upgrade(self) -> RwMutexWriteGuard<'a, T>
Upgrades this upread guard to a write guard atomically.
After calling this method, subsequent readers will be blocked while previous readers remain unaffected.
The calling thread will not sleep, but spin to wait for the existing reader to be released. There are two main reasons.
- First, it needs to sleep in an extra waiting queue and needs extra wake-up logic and overhead.
- Second, upgrading method usually requires a high response time (because the mutex is being used now).
Trait Implementations§
Source§impl<T> Deref for RwMutexUpgradeableGuard<'_, T>
impl<T> Deref for RwMutexUpgradeableGuard<'_, T>
impl<T> !Send for RwMutexUpgradeableGuard<'_, T>
impl<T: Sync> Sync for RwMutexUpgradeableGuard<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for RwMutexUpgradeableGuard<'a, T>
impl<'a, T> !RefUnwindSafe for RwMutexUpgradeableGuard<'a, T>
impl<'a, T> Unpin for RwMutexUpgradeableGuard<'a, T>where
T: Unpin,
impl<'a, T> !UnwindSafe for RwMutexUpgradeableGuard<'a, 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