pub struct CpuMonitor { /* private fields */ }Expand description
Thread-safe CPU load monitor.
Implementations§
Source§impl CpuMonitor
impl CpuMonitor
Sourcepub fn new(config: CpuMonitorConfig) -> Self
pub fn new(config: CpuMonitorConfig) -> Self
Create a new CPU monitor with the given configuration.
Create an Arc-wrapped CPU monitor for sharing across threads.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if monitoring is enabled.
Sourcepub fn check(&self) -> Result<(), CpuOverloaded>
pub fn check(&self) -> Result<(), CpuOverloaded>
Check CPU load and return error if threshold exceeded.
Sourcepub fn maybe_throttle(&self)
pub fn maybe_throttle(&self)
Apply throttle delay if throttling is active.
Sourcepub fn current_load(&self) -> f64
pub fn current_load(&self) -> f64
Get current CPU load.
Sourcepub fn is_throttling(&self) -> bool
pub fn is_throttling(&self) -> bool
Check if throttling is currently active.
Sourcepub fn is_available() -> bool
pub fn is_available() -> bool
Check if CPU monitoring is available on this platform.
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset statistics (for testing).
Trait Implementations§
Source§impl Debug for CpuMonitor
impl Debug for CpuMonitor
Auto Trait Implementations§
impl !Freeze for CpuMonitor
impl RefUnwindSafe for CpuMonitor
impl Send for CpuMonitor
impl Sync for CpuMonitor
impl Unpin for CpuMonitor
impl UnwindSafe for CpuMonitor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more