2023-06-28 21:16:33 -04:00
|
|
|
pub use core::sync::*;
|
2023-07-08 11:29:05 -04:00
|
|
|
pub use alloc::sync::*;
|
2023-06-28 21:16:33 -04:00
|
|
|
|
|
|
|
|
mod mutex_shim {
|
|
|
|
|
#[cfg(feature = "std")]
|
|
|
|
|
pub use std::sync::*;
|
|
|
|
|
#[cfg(not(feature = "std"))]
|
|
|
|
|
pub use spin::*;
|
|
|
|
|
|
|
|
|
|
#[derive(Default, Debug)]
|
|
|
|
|
pub struct ShimMutex<T>(Mutex<T>);
|
|
|
|
|
impl<T> ShimMutex<T> {
|
|
|
|
|
pub const fn new(value: T) -> Self {
|
|
|
|
|
Self(Mutex::new(value))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn lock(&self) -> MutexGuard<'_, T> {
|
|
|
|
|
#[cfg(feature = "std")]
|
|
|
|
|
let res = self.0.lock().unwrap();
|
|
|
|
|
#[cfg(not(feature = "std"))]
|
|
|
|
|
let res = self.0.lock();
|
|
|
|
|
res
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pub use mutex_shim::{ShimMutex as Mutex, MutexGuard};
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "std")]
|
2025-08-19 13:36:01 -04:00
|
|
|
pub use std::sync::{OnceLock, LazyLock};
|
2023-06-28 21:16:33 -04:00
|
|
|
#[cfg(not(feature = "std"))]
|
2025-08-19 13:36:01 -04:00
|
|
|
pub use spin::{Once as OnceLock, Lazy as LazyLock};
|