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 UnsafeUnpin 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.