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 last_wait_kind(&self) -> Option<WaitKind>
pub fn last_wait_kind(&self) -> Option<WaitKind>
What the most recent declared wait, ended or not, was for.
Sourcepub fn stderr_line(&self, raw: &str)
pub fn stderr_line(&self, raw: &str)
One complete stderr line arrived. A wait marker starts a declared
wait, or continues the one in progress (cargo prints package cache
and then build directory; the budget covers the run of them, not
each); any other line ends it. The line is kept for the messages.
Sourcepub fn end_wait(&self)
pub fn end_wait(&self)
The tool wrote something that is not a wait marker: whatever wait was in progress is over, and its length is banked for the note.
Sourcepub fn waiting(&self) -> Option<(WaitKind, Duration)>
pub fn waiting(&self) -> Option<(WaitKind, Duration)>
The declared wait in progress, and how long it has lasted.
Sourcepub fn waited_total(&self) -> Duration
pub fn waited_total(&self) -> Duration
Time spent in declared waits that have ended, plus the one in progress: what a passing check waited for in total.
Sourcepub fn set_load(&self, budget_secs: u64, load: Load, factor_milli: u32)
pub fn set_load(&self, budget_secs: u64, load: Load, factor_milli: u32)
The wait loop read the host’s load and is applying budget_secs.
Sourcepub fn load_scale(&self) -> Option<(u64, Load, u32)>
pub fn load_scale(&self) -> Option<(u64, Load, u32)>
The load-stretched budget in force, with the load behind it, when the host’s load stretched it at all.
Sourcepub fn quiet_for(&self) -> Duration
pub fn quiet_for(&self) -> Duration
How long since it last wrote a byte — the true output silence, what the displays report as “last output”.
Sourcepub fn silence_for(&self) -> Duration
pub fn silence_for(&self) -> Duration
The silence the clock counts: zero while the command is in a
declared wait (it has said what it is doing), the output silence
otherwise. What Activity::still_for and the sampler’s start gate
read; the displays keep Activity::quiet_for.
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::silence_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.