summaryrefslogtreecommitdiffstats
path: root/src/mutex.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-01-08 06:54:39 -0500
committerJesse Luehrs <doy@tozt.net>2022-01-08 07:16:35 -0500
commit43600665dc50abae7f9d90d171cd14f51ba92448 (patch)
tree4a1d914e46a31b174723ef018510323f04f65d70 /src/mutex.rs
parent71df59851586f7221accf95289962fe61c63fb90 (diff)
downloadnbsh-43600665dc50abae7f9d90d171cd14f51ba92448.tar.gz
nbsh-43600665dc50abae7f9d90d171cd14f51ba92448.zip
refactor builtin fd handling a bit
Diffstat (limited to 'src/mutex.rs')
-rw-r--r--src/mutex.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mutex.rs b/src/mutex.rs
new file mode 100644
index 0000000..51192a8
--- /dev/null
+++ b/src/mutex.rs
@@ -0,0 +1,11 @@
+pub type Mutex<T> = async_std::sync::Arc<async_std::sync::Mutex<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 unwrap<T: std::fmt::Debug>(t: Mutex<T>) -> T {
+ async_std::sync::Mutex::into_inner(
+ async_std::sync::Arc::try_unwrap(t).unwrap(),
+ )
+}