pub struct MappedReentrantMutexGuard<'a, R: RawMutex, G: GetThreadId, T: ?Sized + 'a> { /* private fields */ }Expand description
An RAII mutex guard returned by ReentrantMutexGuard::map, which can point to a
subfield of the protected data.
The main difference between MappedReentrantMutexGuard and ReentrantMutexGuard is that the
former doesn’t support temporarily unlocking and re-locking, since that
could introduce soundness issues if the locked object is modified by another
thread.
This structure is created by the map and
try_map, and
try_map_or_err functions on
ReentrantMutexGuard.
Implementations§
Source§impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> MappedReentrantMutexGuard<'a, R, G, T>
impl<'a, R: RawMutex + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> MappedReentrantMutexGuard<'a, R, G, T>
Sourcepub fn map<U: ?Sized, F>(
s: Self,
f: F,
) -> MappedReentrantMutexGuard<'a, R, G, U>
pub fn map<U: ?Sized, F>( s: Self, f: F, ) -> MappedReentrantMutexGuard<'a, R, G, U>
Makes a new MappedReentrantMutexGuard for a component of the locked data.
This is an associated function that needs to be
used as MappedReentrantMutexGuard::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<MappedReentrantMutexGuard<'a, R, G, U>, Self>
pub fn try_map<U: ?Sized, F>( s: Self, f: F, ) -> Result<MappedReentrantMutexGuard<'a, R, G, U>, Self>
Attempts to make a new MappedReentrantMutexGuard 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 MappedReentrantMutexGuard::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<MappedReentrantMutexGuard<'a, R, G, U>, (Self, E)>
pub fn try_map_or_err<U: ?Sized, F, E>( s: Self, f: F, ) -> Result<MappedReentrantMutexGuard<'a, R, G, U>, (Self, E)>
Attempts to make a new MappedReentrantMutexGuard 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 MappedReentrantMutexGuard::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: RawMutexFair + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> MappedReentrantMutexGuard<'a, R, G, T>
impl<'a, R: RawMutexFair + 'a, G: GetThreadId + 'a, T: ?Sized + 'a> MappedReentrantMutexGuard<'a, R, G, T>
Sourcepub fn unlock_fair(s: Self)
pub fn unlock_fair(s: Self)
Releases one level of recursive locking. A fair unlock is performed only if this releases the final level.