1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Poison-resilient locking helpers.
//!
//! A [`std::sync::Mutex`] / [`std::sync::RwLock`] is *poisoned* when a panic
//! unwinds while a guard is held. Every subsequent lock attempt then
//! returns `Err(PoisonError)`, so naive `.lock().unwrap()` call sites turn
//! one contained panic — e.g. a user-supplied
//! [`Generator`](crate::agents::Generator) panicking mid-turn — into a
//! permanently dead shared resource. Worst case: dropping a poisoned
//! [`BruteForceStore`](crate::store::BruteForceStore) during unwind panics
//! inside `Drop` and aborts the whole process.
//!
//! These helpers recover the guard instead. The data guarded through them
//! (vector-store state, generator wrappers, model caches) cannot be left
//! torn by the code that runs under the lock, so "keep going with the data"
//! is the safe choice for a library whose consumers (GUIs) routinely catch
//! panics at frame boundaries.
use ;
/// Lock `m`, recovering the guard if the mutex was poisoned.
pub
/// Unwrap a `Mutex::into_inner()` result, recovering the value on poison.
pub
/// Read-lock `l`, recovering the guard if the lock was poisoned.
pub
/// Write-lock `l`, recovering the guard if the lock was poisoned.
pub