loole 0.4.1

A safe async/sync multi-producer, multi-consumer channel
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pub use StdMutex as Mutex;

#[derive(Debug)]
pub struct StdMutex<T>(std::sync::Mutex<T>);

pub type MutexGuard<'a, T> = std::sync::MutexGuard<'a, T>;

impl<T> StdMutex<T> {
    #[inline(always)]
    pub fn new(t: T) -> Self {
        Self(std::sync::Mutex::new(t))
    }

    #[inline(always)]
    pub fn lock(&self) -> MutexGuard<T> {
        self.0.lock().unwrap_or_else(|e| e.into_inner())
    }
}