std_shims/
sync.rs

1pub use core::sync::*;
2pub use alloc::sync::*;
3
4mod mutex_shim {
5  #[cfg(feature = "std")]
6  pub use std::sync::*;
7  #[cfg(not(feature = "std"))]
8  pub use spin::*;
9
10  #[derive(Default, Debug)]
11  pub struct ShimMutex<T>(Mutex<T>);
12  impl<T> ShimMutex<T> {
13    pub const fn new(value: T) -> Self {
14      Self(Mutex::new(value))
15    }
16
17    pub fn lock(&self) -> MutexGuard<'_, T> {
18      #[cfg(feature = "std")]
19      let res = self.0.lock().unwrap();
20      #[cfg(not(feature = "std"))]
21      let res = self.0.lock();
22      res
23    }
24  }
25}
26pub use mutex_shim::{ShimMutex as Mutex, MutexGuard};
27
28#[cfg(feature = "std")]
29pub use std::sync::LazyLock;
30#[cfg(not(feature = "std"))]
31pub use spin::Lazy as LazyLock;