Skip to main content

Activity

Struct Activity 

Source
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

Source

pub fn new() -> Arc<Activity> ⓘ

Source

pub fn touch(&self)

It wrote something.

Source

pub fn quiet_for(&self) -> Duration

How long since it last wrote a byte.

Source

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.

Source

pub fn cpu_state(&self) -> CpuState

Source

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.

Source

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.

Source

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.

Source

pub fn enable_cpu(&self)

Sampling is on for this command.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.