diff options
Diffstat (limited to 'src/mutex.rs')
-rw-r--r-- | src/mutex.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mutex.rs b/src/mutex.rs index aca5669..1c6faff 100644 --- a/src/mutex.rs +++ b/src/mutex.rs @@ -1,9 +1,14 @@ pub type Mutex<T> = async_std::sync::Arc<async_std::sync::Mutex<T>>; +pub type Guard<T> = async_std::sync::MutexGuardArc<T>; pub fn new<T>(t: T) -> async_std::sync::Arc<async_std::sync::Mutex<T>> { async_std::sync::Arc::new(async_std::sync::Mutex::new(t)) } +pub fn clone<T>(m: &Mutex<T>) -> Mutex<T> { + async_std::sync::Arc::clone(m) +} + pub fn unwrap<T: std::fmt::Debug>(t: Mutex<T>) -> Option<T> { if let Ok(mutex) = async_std::sync::Arc::try_unwrap(t) { Some(async_std::sync::Mutex::into_inner(mutex)) |