mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Preserves the fn accessors within the Monero crates so that we can use statics in some cfgs yet not all (in order to provide support for more low-memory devices) with the exception of `H` (which truly should be cached).
32 lines
707 B
Rust
32 lines
707 B
Rust
pub use core::sync::*;
|
|
pub use alloc::sync::*;
|
|
|
|
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")]
|
|
pub use std::sync::LazyLock;
|
|
#[cfg(not(feature = "std"))]
|
|
pub use spin::Lazy as LazyLock;
|