Acquire a read guard, recovering from poison if the lock was poisoned. Non-security code should never panic on a poisoned lock. The data may be in an inconsistent state, but crashing the entire process is worse than serving stale data in a coding agent context.
(lock: &std::sync::RwLock<T>)
| 94 | /// be in an inconsistent state, but crashing the entire process is worse |
| 95 | /// than serving stale data in a coding agent context. |
| 96 | pub(crate) fn read_or_recover<T>(lock: &std::sync::RwLock<T>) -> std::sync::RwLockReadGuard<'_, T> { |
| 97 | lock.read().unwrap_or_else(|p| p.into_inner()) |
| 98 | } |
| 99 | |
| 100 | /// Acquire a write guard, recovering from poison if the lock was poisoned. |
| 101 | /// |
no outgoing calls