pub struct Meter { /* private fields */ }Expand description
A lock-free progress meter shared across threads behind an
Arc.
Every method takes &self and uses Ordering::Relaxed — the counters are
advisory progress, never a synchronization primitive, so relaxed ordering is
both correct and cheap (a couple of atomic ops per file). Meter is
Send + Sync because all of its fields are atomics.
Implementations§
Source§impl Meter
impl Meter
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a fresh meter with all counters at zero and Phase::Idle.
Sourcepub fn object_started(&self)
pub fn object_started(&self)
Records that an object started: bumps the in-flight gauge by one.
Sourcepub fn object_finished(&self)
pub fn object_finished(&self)
Records that an object finished: drops the in-flight gauge by one and bumps the done counter by one. Saturates the gauge at zero so a stray finish never underflows.
Sourcepub fn add_skipped(&self, n: u64)
pub fn add_skipped(&self, n: u64)
Adds n to the skipped-objects counter.
Sourcepub fn set_current_limit(&self, n: u64)
pub fn set_current_limit(&self, n: u64)
Sets the advisory adaptive throughput limit (bytes/sec; 0 = unset).
Display-only: the renderer reads this to show the live adaptive value. It does not throttle or otherwise change the walk’s behavior or output.
Sourcepub fn set_target_rate(&self, n: u64)
pub fn set_target_rate(&self, n: u64)
Sets the advisory adaptive target throughput (bytes/sec; 0 = unset).
Display-only, with the same advisory semantics as
set_current_limit.
Sourcepub fn snapshot(&self) -> MeterSnapshot
pub fn snapshot(&self) -> MeterSnapshot
Takes a point-in-time MeterSnapshot of every counter.
The loads are independently relaxed, so the snapshot is eventually consistent rather than a single atomic view — that is fine for an advisory progress display.