#[cfg(feature = "std")]
pub use std::{
boxed::Box,
collections::HashMap,
string::String,
sync::Arc,
time::{Duration, Instant},
vec::Vec,
};
#[cfg(not(feature = "std"))]
pub use alloc::{boxed::Box, collections::HashMap, string::String, sync::Arc, vec::Vec};
#[cfg(not(feature = "std"))]
pub use core::time::Duration;
#[cfg(feature = "std")]
pub use std::sync::atomic::{
AtomicBool, AtomicPtr, AtomicU32, AtomicU64, AtomicUsize, Ordering, compiler_fence, fence,
};
#[cfg(not(feature = "std"))]
pub use core::sync::atomic::{
AtomicBool, AtomicPtr, AtomicU32, AtomicU64, AtomicUsize, Ordering, compiler_fence, fence,
};
#[cfg(feature = "std")]
pub use std::cell::{Cell, RefCell, UnsafeCell};
#[cfg(not(feature = "std"))]
pub use core::cell::{Cell, RefCell, UnsafeCell};
#[cfg(feature = "std")]
pub use std::mem::{self, MaybeUninit, align_of, forget, replace, size_of, swap};
#[cfg(not(feature = "std"))]
pub use core::mem::{self, MaybeUninit, align_of, forget, replace, size_of, swap};
#[cfg(feature = "std")]
pub use std::ptr::{self, NonNull, null, null_mut};
#[cfg(not(feature = "std"))]
pub use core::ptr::{self, NonNull, null, null_mut};
#[cfg(feature = "std")]
pub use std::marker::{PhantomData, Send, Sync};
#[cfg(not(feature = "std"))]
pub use core::marker::{PhantomData, Send, Sync};
#[cfg(feature = "std")]
pub use std::ops::{Deref, DerefMut, Drop, Fn, FnMut, FnOnce};
#[cfg(not(feature = "std"))]
pub use core::ops::{Deref, DerefMut, Drop, Fn, FnMut, FnOnce};
#[cfg(feature = "std")]
pub use std::fmt::{self, Debug, Display};
#[cfg(not(feature = "std"))]
pub use core::fmt::{self, Debug, Display};
#[cfg(not(feature = "std"))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct Instant(u64);
#[cfg(not(feature = "std"))]
impl Instant {
pub fn now() -> Self {
static COUNTER: AtomicU64 = AtomicU64::new(0);
Instant(COUNTER.fetch_add(1, Ordering::Relaxed))
}
pub fn duration_since(&self, earlier: Instant) -> Duration {
let nanos = self.0.saturating_sub(earlier.0);
Duration::from_nanos(nanos)
}
pub fn elapsed(&self) -> Duration {
Instant::now().duration_since(*self)
}
}
#[cfg(feature = "std")]
pub use std::sync::{Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
#[cfg(not(feature = "std"))]
pub use spin::{Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
pub mod channel {
#[cfg(feature = "std")]
pub use std::sync::mpsc::{Receiver, RecvError, Sender, TryRecvError, channel};
#[cfg(not(feature = "std"))]
pub use alloc::sync::mpsc::{Receiver, RecvError, Sender, TryRecvError, channel};
}
pub mod thread {
#[cfg(feature = "std")]
pub use std::thread::{JoinHandle, Thread, ThreadId, sleep, spawn, yield_now};
#[cfg(not(feature = "std"))]
compile_error!("Thread support requires std feature");
}