Skip to main content

MutexExt

Trait MutexExt 

Source
pub trait MutexExt<T> {
    // Required methods
    fn lock_safe(&self) -> T
       where T: Clone;
    fn lock_mut_safe(&self) -> MutexGuard<'_, T>;
}
Expand description

Extension trait for Mutex to provide safe lock operations

Required Methods§

Source

fn lock_safe(&self) -> T
where T: Clone,

Lock the mutex, recovering from poison errors This is safer than unwrap() as it handles poisoned mutexes gracefully

Source

fn lock_mut_safe(&self) -> MutexGuard<'_, T>

Lock the mutex for mutation, recovering from poison errors

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: Clone> MutexExt<T> for Mutex<T>

Source§

fn lock_safe(&self) -> T

Source§

fn lock_mut_safe(&self) -> MutexGuard<'_, T>

Implementors§