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))] 8 // Use "wide" sequence lock if the pointer width <= 32 for preventing its counter against wrap 9 // around. 10 // 11 // In narrow architectures (pointer width <= 16), the counter is still <= 32-bit and may be 12 // vulnerable to wrap around. But it's mostly okay, since in such a primitive hardware, the 13 // counter will not be increased that fast. 14 // Note that Rust (and C99) pointers must be at least 16-bit (i.e., 8-bit targets are impossible): https://github.com/rust-lang/rust/pull/49305 15 #[cfg_attr( 16 any(target_pointer_width = "16", target_pointer_width = "32"), 17 path = "seq_lock_wide.rs" 18 )] 19 mod seq_lock; 20 21 #[cfg(target_has_atomic = "ptr")] 22 // We cannot provide AtomicCell under cfg(crossbeam_loom) because loom's atomic 23 // types have a different in-memory representation than the underlying type. 24 // TODO: The latest loom supports fences, so fallback using seqlock may be available. 25 #[cfg(not(crossbeam_loom))] 26 mod atomic_cell; 27 #[cfg(target_has_atomic = "ptr")] 28 #[cfg(not(crossbeam_loom))] 29 pub use atomic_cell::AtomicCell; 30 31 mod consume; 32 pub use consume::AtomicConsume; 33