pub fn acquire_mutex<'a, T>(
lock: &'a Mutex<T>,
lock_name: &'static str,
) -> Result<MutexGuard<'a, T>, LockPoisonedError>Expand description
Acquires a mutex lock, returning an error if the lock is poisoned.
§Errors
Returns LockPoisonedError if another thread panicked while holding this lock.
§Examples
use std::sync::Mutex;
use uni_common::sync::acquire_mutex;
let lock = Mutex::new(42);
let guard = acquire_mutex(&lock, "my_data").unwrap();
assert_eq!(*guard, 42);