1 2 3 4 5 6 7 8 9 10 11 12 13
use std::sync::atomic::{AtomicU64, Ordering}; pub struct AtomicCounter(AtomicU64); impl AtomicCounter { pub const fn new() -> Self { Self(AtomicU64::new(1)) } pub fn next(&self) -> u64 { self.0.fetch_add(1, Ordering::Relaxed) } }