mycelium_util/sync.rs
1//! Synchronization primitives, and utilities for implementing them.
2
3#[cfg(loom)]
4pub use loom::sync::atomic;
5
6#[cfg(not(loom))]
7pub use core::sync::atomic;
8
9pub mod cell;
10
11pub use self::once::{InitOnce, Lazy};
12pub use maitake_sync::blocking;
13pub use maitake_sync::{spin::once, util::CachePadded};
14
15/// Spinlocks and related synchronization primitives.
16pub mod spin {
17 pub use maitake_sync::{spin::*, util::Backoff};
18}
19/// A wrapper for the [`core::hint`] module that emits either [`loom`] spin loop
20/// hints (when `cfg(loom)` is enabled), or real spin loop hints when loom is
21/// not enabled.
22///
23/// [`loom`]: https://crates.io/crates/loom
24pub mod hint {
25 #[cfg(not(loom))]
26 pub use core::hint::spin_loop;
27
28 #[cfg(loom)]
29 pub use loom::sync::atomic::spin_loop_hint as spin_loop;
30}