pub struct SessionCounters { /* private fields */ }Expand description
Atomic counter array shared between session and torrent actors.
All values are AtomicI64 — counters are incremented, gauges are set.
The struct is Send + Sync (auto-derived from AtomicI64).
Implementations§
Source§impl SessionCounters
impl SessionCounters
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new counter array with all values initialised to zero and diagnostic counters disabled.
Sourcepub fn new_with_diagnostics(enabled: bool) -> Self
pub fn new_with_diagnostics(enabled: bool) -> Self
Create a new counter array with diagnostic counters enabled.
Sourcepub fn diagnostics_enabled(&self) -> bool
pub fn diagnostics_enabled(&self) -> bool
Whether diagnostic counters (indices >= DIAGNOSTIC_COUNTERS_START)
are being incremented.
Sourcepub fn inc_diag(&self, metric: usize, delta: i64)
pub fn inc_diag(&self, metric: usize, delta: i64)
Like Self::inc but only increments when diagnostic counters are
enabled. Use for indices >= DIAGNOSTIC_COUNTERS_START.
Sourcepub fn set_max_diag(&self, metric: usize, value: i64)
pub fn set_max_diag(&self, metric: usize, value: i64)
Like Self::set_max but only updates when diagnostic counters are
enabled. Use for indices >= DIAGNOSTIC_COUNTERS_START.
Sourcepub fn set_max(&self, metric: usize, value: i64)
pub fn set_max(&self, metric: usize, value: i64)
Atomically update a high-water gauge: store value only when it
exceeds the current value. Used by the sim-perf surface to track
the peak depth observed for EVENT_TX_HIGH_WATER and
DISPATCH_TX_HIGH_WATER. Race-tolerant — the worst case is a
missed update on a tied write.
Sourcepub fn snapshot(&self) -> Vec<i64>
pub fn snapshot(&self) -> Vec<i64>
Take a consistent snapshot of all metric values.
Also updates the uptime gauge and computes bandwidth rate deltas (upload/download rate = bytes since last snapshot).
Sourcepub fn uptime_secs(&self) -> u64
pub fn uptime_secs(&self) -> u64
Seconds elapsed since the session was created.