1//! Atomic types.
2//!
3//! * [`AtomicCell`], a thread-safe mutable memory location.
4//! * [`AtomicConsume`], for reading from primitive atomic types with "consume" ordering.
5
6#[cfg(target_has_atomic = "ptr")]
7#[cfg(not(crossbeam_loom))]
8cfg_if::cfg_if! {
9 // Use "wide" sequence lock if the pointer width <= 32 for preventing its counter against wrap
10 // around.
11 //
12 // We are ignoring too wide architectures (pointer width >= 256), since such a system will not
13 // appear in a conceivable future.
14 //
15 // In narrow architectures (pointer width <= 16), the counter is still <= 32-bit and may be
16 // vulnerable to wrap around. But it's mostly okay, since in such a primitive hardware, the
17 // counter will not be increased that fast.
18 if #[cfg(any(target_pointer_width = "64", target_pointer_width = "128"))] {
19 mod seq_lock;
20 } else {
21 #[path = "seq_lock_wide.rs"]
22 mod seq_lock;
23 }
24}
25
26#[cfg(target_has_atomic = "ptr")]
27// We cannot provide AtomicCell under cfg(crossbeam_loom) because loom's atomic
28// types have a different in-memory representation than the underlying type.
29// TODO: The latest loom supports fences, so fallback using seqlock may be available.
30#[cfg(not(crossbeam_loom))]
31mod atomic_cell;
32mod consume;
33
34#[cfg(target_has_atomic = "ptr")]
35#[cfg(not(crossbeam_loom))]
36pub use self::atomic_cell::AtomicCell;
37pub use self::consume::AtomicConsume;
38