use std::sync::atomic::{AtomicU64, Ordering};
#[derive(Debug)]
pub struct AtomicToolCounter {
count: AtomicU64,
failures: AtomicU64,
}
impl AtomicToolCounter {
pub fn new() -> Self {
Self {
count: AtomicU64::new(0),
failures: AtomicU64::new(0),
}
}
pub fn record(&self, success: bool) {
self.count.fetch_add(1, Ordering::Relaxed);
if !success {
self.failures.fetch_add(1, Ordering::Relaxed);
}
}
pub fn get(&self) -> (u64, u64) {
(
self.count.load(Ordering::Relaxed),
self.failures.load(Ordering::Relaxed),
)
}
}
impl Default for AtomicToolCounter {
fn default() -> Self {
Self::new()
}
}