sea_streamer_runtime/
mutex.rs

1#[cfg(feature = "runtime-tokio")]
2pub use tokio::sync::Mutex as AsyncMutex;
3
4#[cfg(feature = "runtime-async-std")]
5pub use async_std::sync::Mutex as AsyncMutex;
6
7#[cfg(not(any(feature = "runtime-tokio", feature = "runtime-async-std")))]
8mod no_rt_mutex {
9    use std::ops::{Deref, DerefMut};
10
11    pub struct AsyncMutex<T> {
12        m: std::marker::PhantomData<T>,
13    }
14
15    impl<T> AsyncMutex<T> {
16        pub fn new(_: T) -> Self {
17            Self {
18                m: Default::default(),
19            }
20        }
21
22        pub async fn lock(&self) -> Self {
23            Self {
24                m: Default::default(),
25            }
26        }
27    }
28
29    impl<T> Deref for AsyncMutex<T> {
30        type Target = T;
31
32        fn deref(&self) -> &Self::Target {
33            unimplemented!("Please enable a runtime")
34        }
35    }
36
37    impl<T> DerefMut for AsyncMutex<T> {
38        fn deref_mut(&mut self) -> &mut Self::Target {
39            unimplemented!("Please enable a runtime")
40        }
41    }
42}
43
44#[cfg(not(any(feature = "runtime-tokio", feature = "runtime-async-std")))]
45pub use no_rt_mutex::*;