Struct guardian::ArcRwLockWriteGuardian
source · pub struct ArcRwLockWriteGuardian<T: 'static> { /* private fields */ }
Expand description
RAII structure used to release the exclusive write access of a lock when dropped.
Keeps a handle to an Arc
so that the lock is not dropped until the guard is.
The data protected by the mutex can be access through this guard via its Deref
and DerefMut
implementations.
Implementations§
source§impl<T> ArcRwLockWriteGuardian<T>
impl<T> ArcRwLockWriteGuardian<T>
sourcepub fn take(handle: Arc<RwLock<T>>) -> LockResult<ArcRwLockWriteGuardian<T>>
pub fn take(handle: Arc<RwLock<T>>) -> LockResult<ArcRwLockWriteGuardian<T>>
Locks this rwlock with exclusive write access, blocking the current thread until it can be acquired.
This function will not return while other writers or other readers currently have access to the lock.
Returns an RAII guard which will drop the write access of this rwlock when dropped.
The guardian also holds a strong reference to the lock’s Arc
, which is dropped when the
guard is.
Errors
This function will return an error if the RwLock
is poisoned. An RwLock
is poisoned
whenever a writer panics while holding an exclusive lock. An error will be returned when
the lock is acquired.