#[cfg(not(feature = "shuttle"))]
pub(crate) use core::sync::atomic::{AtomicBool, AtomicIsize, AtomicU64, AtomicUsize};
#[cfg(feature = "shuttle")]
pub(crate) use shuttle::sync::atomic::{AtomicBool, AtomicIsize, AtomicU64, AtomicUsize};
#[inline(always)]
pub(crate) fn spin_hint() {
#[cfg(feature = "shuttle")]
{
shuttle::hint::spin_loop();
}
#[cfg(not(feature = "shuttle"))]
{
core::hint::spin_loop();
#[cfg(feature = "std")]
if PAUSES
.try_with(|pauses| {
let n = pauses.get().wrapping_add(1);
pauses.set(n);
n % 64 == 0
})
.unwrap_or(false)
{
std::thread::yield_now();
}
}
}
#[cfg(all(feature = "std", not(feature = "shuttle")))]
std::thread_local! {
static PAUSES: core::cell::Cell<u32> = const { core::cell::Cell::new(0) };
}