pub struct RwLockWriteGuard<'a, R: RawRwLock, T: ?Sized> { /* private fields */ }Expand description
Implementations§
Source§impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T>
impl<'a, R: RawRwLock + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T>
Sourcepub fn rwlock(s: &Self) -> &'a RwLock<R, T>
pub fn rwlock(s: &Self) -> &'a RwLock<R, T>
Returns a reference to the original reader-writer lock object.
Sourcepub fn map<U: ?Sized, F>(s: Self, f: F) -> MappedRwLockWriteGuard<'a, R, U>
pub fn map<U: ?Sized, F>(s: Self, f: F) -> MappedRwLockWriteGuard<'a, R, U>
Makes a new MappedRwLockWriteGuard for a component of the locked data.
This is an associated function that needs to be
used as RwLockWriteGuard::map(...). A method would interfere with methods of
the same name on the contents of the locked data.
§Panics
If f panics, the original guard is dropped.
Sourcepub fn try_map<U: ?Sized, F>(
s: Self,
f: F,
) -> Result<MappedRwLockWriteGuard<'a, R, U>, Self>
pub fn try_map<U: ?Sized, F>( s: Self, f: F, ) -> Result<MappedRwLockWriteGuard<'a, R, U>, Self>
Attempts to make a new MappedRwLockWriteGuard for a component of the
locked data. The original guard is returned if the closure returns None.
This is an associated function that needs to be
used as RwLockWriteGuard::try_map(...). A method would interfere with methods of
the same name on the contents of the locked data.
§Panics
If f panics, the original guard is dropped.
Sourcepub fn try_map_or_err<U: ?Sized, F, E>(
s: Self,
f: F,
) -> Result<MappedRwLockWriteGuard<'a, R, U>, (Self, E)>
pub fn try_map_or_err<U: ?Sized, F, E>( s: Self, f: F, ) -> Result<MappedRwLockWriteGuard<'a, R, U>, (Self, E)>
Attempts to make a new MappedRwLockWriteGuard for a component of the
locked data. The original guard is returned alongside arbitrary user data
if the closure returns Err.
This is an associated function that needs to be
used as RwLockWriteGuard::try_map_or_err(...). A method would interfere with methods of
the same name on the contents of the locked data.
§Panics
If f panics, the original guard is dropped.
Source§impl<'a, R: RawRwLockDowngrade + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T>
impl<'a, R: RawRwLockDowngrade + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T>
Sourcepub fn downgrade(s: Self) -> RwLockReadGuard<'a, R, T>
pub fn downgrade(s: Self) -> RwLockReadGuard<'a, R, T>
Atomically downgrades a write lock into a read lock without allowing any writers to take exclusive access of the lock in the meantime.
Note that if there are any writers currently waiting to take the lock then other readers may not be able to acquire the lock even if it was downgraded.
Source§impl<'a, R: RawRwLockUpgradeDowngrade + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T>
impl<'a, R: RawRwLockUpgradeDowngrade + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T>
Sourcepub fn downgrade_to_upgradable(s: Self) -> RwLockUpgradableReadGuard<'a, R, T>
pub fn downgrade_to_upgradable(s: Self) -> RwLockUpgradableReadGuard<'a, R, T>
Atomically downgrades a write lock into an upgradable read lock without allowing any writers to take exclusive access of the lock in the meantime.
Note that if there are any writers currently waiting to take the lock then other readers may not be able to acquire the lock even if it was downgraded.
Source§impl<'a, R: RawRwLockFair + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T>
impl<'a, R: RawRwLockFair + 'a, T: ?Sized + 'a> RwLockWriteGuard<'a, R, T>
Sourcepub fn unlock_fair(s: Self)
pub fn unlock_fair(s: Self)
Unlocks the RwLock using a fair unlock protocol.
A fair unlock gives waiting threads priority over new acquisition attempts. This can prevent starvation, but may reduce throughput by forcing a context switch.
Sourcepub fn unlocked_fair<F, U>(s: &mut Self, f: F) -> Uwhere
F: FnOnce() -> U,
pub fn unlocked_fair<F, U>(s: &mut Self, f: F) -> Uwhere
F: FnOnce() -> U,
Temporarily unlocks the RwLock to execute the given function.
The RwLock is unlocked using a fair unlock protocol.
This is safe because &mut guarantees that there exist no other
references to the data protected by the RwLock.
§Aborts
Aborts if re-locking the RwLock panics.