Skip to main content

Module sync

Module sync 

Source
Expand description

Poison-recovering lock extensions.

The SDK runs on mobile platforms where a process crash is worse than operating on potentially inconsistent state. A panic on one thread while holding a lock poisons it; with plain .lock().unwrap() every later access panics too, permanently wedging the node. Mutex poisoning in Rust is advisory — the protected data is still structurally valid — so these helpers recover the guard via std::sync::PoisonError::into_inner and log a warning with the caller’s location for observability.

Use these in code driven by foreign (FFI) threads and in event-emission paths that must keep flowing. Test code should keep .lock().unwrap() so poisoning fails loudly.

Traits§

MutexExt
Extension trait adding poison-recovering locking to Mutex.
RwLockExt
Extension trait adding poison-recovering locking to RwLock.