virtx 0.1.1

Run tasks in disposable Linux VMs from your own code: the environment an agent works in.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Locking that survives a panic somewhere else.

use std::sync::{Mutex, MutexGuard};

/// Lock `mutex`, ignoring poisoning.
///
/// Locks nest (directory node → child), so unwrapping a poisoned child panics while
/// the parent is held, poisoning it too, until every operation on the volume panics. Each lock
/// guards a single insert/remove/resize, so poison means another thread panicked, not that the
/// data is half-written.
pub(crate) fn lock<T>(mutex: &Mutex<T>) -> MutexGuard<'_, T> {
    mutex
        .lock()
        .unwrap_or_else(|poisoned| poisoned.into_inner())
}