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};
|
|
|
|
|
|
2025-08-19 17:40:19 -04:00
|
|
|
#[cfg(not(feature = "std"))]
|
|
|
|
|
pub use spin::Lazy as LazyLock;
|
2025-08-19 18:10:33 -04:00
|
|
|
#[rustversion::before(1.80)]
|
2025-08-19 17:40:19 -04:00
|
|
|
#[cfg(feature = "std")]
|
2025-08-19 18:10:33 -04:00
|
|
|
pub use spin::Lazy as LazyLock;
|
|
|
|
|
#[rustversion::since(1.80)]
|
2025-08-19 17:40:19 -04:00
|
|
|
#[cfg(feature = "std")]
|
2025-08-19 18:10:33 -04:00
|
|
|
pub use std::sync::LazyLock;
|