pub struct Activity { /* private fields */ }Expand description
What a spawned command has been doing, shared between the reader threads
that see its bytes, the CPU sampler, the wait loop that judges it, and the
progress displays. Every field is an atomic offset from base, so the
80 ms repaint and the 25 ms wait loop read it without a lock.
Two clocks, kept apart on purpose: last_out is when it last WROTE (what
the messages report as “last output”), last_busy is the start of the
last window in which its process tree did measurable CPU work. The kill
decision uses the later of the two (Activity::still_for).
Implementations§
Source§impl Activity
impl Activity
pub fn new() -> Arc<Activity> ⓘ
Sourcepub fn still_for(&self) -> Duration
pub fn still_for(&self) -> Duration
How long it has been BOTH silent and idle on CPU — the number the
silence budget is judged against. Equals Activity::quiet_for
whenever CPU is not sampled.
pub fn cpu_state(&self) -> CpuState
Sourcepub fn fresh_rate(&self) -> Option<u32>
pub fn fresh_rate(&self) -> Option<u32>
The last measured rate in thousandths of a core, while it is fresh:
None once two sampling intervals have passed without a complete
window, so a display never keeps showing “busy” on stale data.
Sourcepub fn verdict(&self) -> CpuVerdict
pub fn verdict(&self) -> CpuVerdict
What the CPU side can honestly say at a kill. “Measured idle” names the unbroken span of complete measurements it rests on — sampling starts only after a stretch of silence, so that span is always shorter than the silence itself, and nothing is claimed about the rest.
Sourcepub fn record(&self, obs: Observation, at: Instant, interval: Duration)
pub fn record(&self, obs: Observation, at: Instant, interval: Duration)
Feed one sampler observation in. interval is the sampling period,
kept so displays can tell a fresh rate from a stale one.
Sourcepub fn enable_cpu(&self)
pub fn enable_cpu(&self)
Sampling is on for this command.