#![allow(unused_imports)]
#[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::{
compiler_fence, fence, AtomicBool, AtomicPtr, AtomicU32, AtomicU64, AtomicUsize, Ordering,
};
#[cfg(not(feature = "std"))]
pub use core::sync::atomic::{
compiler_fence, fence, AtomicBool, AtomicPtr, AtomicU32, AtomicU64, AtomicUsize, Ordering,
};
#[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, align_of, forget, replace, size_of, swap, MaybeUninit};
#[cfg(not(feature = "std"))]
pub use core::mem::{self, align_of, forget, replace, size_of, swap, MaybeUninit};
#[cfg(feature = "std")]
pub use std::ptr::{self, null, null_mut, NonNull};
#[cfg(not(feature = "std"))]
pub use core::ptr::{self, null, null_mut, NonNull};
#[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::{channel, Receiver, RecvError, Sender, TryRecvError};
#[cfg(not(feature = "std"))]
pub use alloc::sync::mpsc::{channel, Receiver, RecvError, Sender, TryRecvError};
}
pub mod thread {
#[cfg(feature = "std")]
pub use std::thread::{sleep, spawn, yield_now, JoinHandle, Thread, ThreadId};
#[cfg(not(feature = "std"))]
compile_error!("Thread support requires std feature");
}