pub struct LockGuard { /* private fields */ }Expand description
RAII guard returned by Lock::lock and Lock::try_lock.
Releases the lock — both the OS primitive and the thread gate — when
dropped. The guard keeps the Lock’s backing state alive, so it is
safe to drop the originating Lock while the guard is still live.
On Windows, if the previous mutex owner terminated without releasing the
lock, the waiting acquisition succeeds but LockGuard::is_abandoned
returns true. This can indicate that shared state protected by the lock
may be inconsistent. On Unix this method always returns false.
Implementations§
Source§impl LockGuard
impl LockGuard
Sourcepub fn is_abandoned(&self) -> bool
pub fn is_abandoned(&self) -> bool
Returns true if the lock was acquired from an abandoned owner.
This only happens on Windows when the previous owner of the named kernel mutex terminated without releasing the mutex. It signals that any shared state protected by the lock may be in an inconsistent state and should be inspected before reuse.
On Unix this method always returns false.