use std::sync::atomic::{AtomicU64, Ordering};
pub static ACQUISITIONS_TOTAL: AtomicU64 = AtomicU64::new(0);
pub static CONTENTION_EVENTS_TOTAL: AtomicU64 = AtomicU64::new(0);
pub static RENEWAL_FAILURES_TOTAL: AtomicU64 = AtomicU64::new(0);
#[inline]
pub(crate) fn inc_acquisitions() {
ACQUISITIONS_TOTAL.fetch_add(1, Ordering::Relaxed);
}
#[inline]
pub(crate) fn inc_contention() {
CONTENTION_EVENTS_TOTAL.fetch_add(1, Ordering::Relaxed);
}
#[inline]
pub(crate) fn inc_renewal_failures() {
RENEWAL_FAILURES_TOTAL.fetch_add(1, Ordering::Relaxed);
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Snapshot {
pub acquisitions_total: u64,
pub contention_events_total: u64,
pub renewal_failures_total: u64,
}
pub fn snapshot() -> Snapshot {
Snapshot {
acquisitions_total: ACQUISITIONS_TOTAL.load(Ordering::Relaxed),
contention_events_total: CONTENTION_EVENTS_TOTAL.load(Ordering::Relaxed),
renewal_failures_total: RENEWAL_FAILURES_TOTAL.load(Ordering::Relaxed),
}
}