Expand description
Poison-tolerant locking for std::sync::Mutex.
std::sync::Mutex poisoning is advisory bookkeeping: a guard dropped while
panicking flags the mutex, but the guarded value is often still consistent.
Panicking on every subsequent lock() turns one localized failure into a
process-wide cascade, especially for process-global state and cleanup paths.
VT Code’s policy:
- short synchronous critical sections use
parking_lot::Mutex(no poison); - where
std::sync::Mutexis required, uselock_or_recoverso poison is recovered instead of propagated; - callers with a genuine mid-critical-section invariant should model poison explicitly rather than relying on the standard library’s boolean flag.
Functions§
- lock_
or_ recover - Lock
mutex, returning the guard even if a previous holder panicked.