Skip to main content

CpuMonitor

Struct CpuMonitor 

Source
pub struct CpuMonitor { /* private fields */ }
Expand description

Thread-safe CPU load monitor.

Implementations§

Source§

impl CpuMonitor

Source

pub fn new(config: CpuMonitorConfig) -> Self

Create a new CPU monitor with the given configuration.

Source

pub fn disabled() -> Self

Create a disabled CPU monitor.

Source

pub fn shared(config: CpuMonitorConfig) -> Arc<Self>

Create an Arc-wrapped CPU monitor for sharing across threads.

Source

pub fn is_enabled(&self) -> bool

Check if monitoring is enabled.

Source

pub fn sample(&self) -> Option<f64>

Sample current CPU load and update statistics.

Source

pub fn check(&self) -> Result<(), CpuOverloaded>

Check CPU load and return error if threshold exceeded.

Source

pub fn maybe_throttle(&self)

Apply throttle delay if throttling is active.

Source

pub fn stats(&self) -> CpuStats

Get current statistics.

Source

pub fn current_load(&self) -> f64

Get current CPU load.

Source

pub fn is_throttling(&self) -> bool

Check if throttling is currently active.

Source

pub fn is_available() -> bool

Check if CPU monitoring is available on this platform.

Source

pub fn reset_stats(&self)

Reset statistics (for testing).

Trait Implementations§

Source§

impl Debug for CpuMonitor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CpuMonitor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V