1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Copyright 2022-2022 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT use std::sync::atomic::{AtomicU32, Ordering}; pub struct Counter(AtomicU32); impl Counter { pub const fn new() -> Self { Self(AtomicU32::new(1)) } pub fn next(&self) -> u32 { self.0.fetch_add(1, Ordering::Relaxed) } }