use std::sync::atomic::{AtomicUsize, Ordering};
#[derive(Default, Debug)]
pub struct FastCounter {
counter: AtomicUsize,
}
impl FastCounter {
#[inline]
pub fn incr(&self) {
self.counter.fetch_add(1, Ordering::Relaxed);
}
#[inline]
pub fn decr(&self) {
self.counter.fetch_sub(1, Ordering::Relaxed);
}
pub fn count(&self) -> usize {
self.counter.load(Ordering::Relaxed)
}
}