pub struct ResourceMonitor<T: Float + Debug + Send + Sync + 'static> { /* private fields */ }Expand description
Resource monitor for tracking evaluation resources
Implementations§
Source§impl<T: Float + Debug + Default + Send + Sync> ResourceMonitor<T>
impl<T: Float + Debug + Default + Send + Sync> ResourceMonitor<T>
Sourcepub fn stop_monitoring(&mut self)
pub fn stop_monitoring(&mut self)
Stop monitoring
Sourcepub fn get_current_usage(&self) -> &ResourceUsage<T>
pub fn get_current_usage(&self) -> &ResourceUsage<T>
Get current resource usage
Sourcepub fn set_current_usage(&mut self, usage: ResourceUsage<T>)
pub fn set_current_usage(&mut self, usage: ResourceUsage<T>)
Replace the tracked current usage with a freshly measured record.
Sourcepub fn get_limits(&self) -> &ResourceLimits<T>
pub fn get_limits(&self) -> &ResourceLimits<T>
Get resource limits
Sourcepub fn set_limits(&mut self, limits: ResourceLimits<T>)
pub fn set_limits(&mut self, limits: ResourceLimits<T>)
Set resource limits
Sourcepub fn get_config(&self) -> &MonitoringConfig
pub fn get_config(&self) -> &MonitoringConfig
Get monitoring configuration
Sourcepub fn set_config(&mut self, config: MonitoringConfig)
pub fn set_config(&mut self, config: MonitoringConfig)
Set monitoring configuration
Sourcepub fn record_snapshot(&mut self, snapshot: ResourceUsageSnapshot<T>)
pub fn record_snapshot(&mut self, snapshot: ResourceUsageSnapshot<T>)
Record a resource snapshot
Sourcepub fn get_history(&self) -> &VecDeque<ResourceUsageSnapshot<T>>
pub fn get_history(&self) -> &VecDeque<ResourceUsageSnapshot<T>>
Get usage history
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear history
Sourcepub fn check_limits(&self) -> bool
pub fn check_limits(&self) -> bool
Check whether the currently tracked usage stays inside the configured
limits. Returns true when every tracked resource is within budget.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for ResourceMonitor<T>where
ResourceUsage<T>: Freeze,
VecDeque<ResourceUsageSnapshot<T>>: Freeze,
ResourceLimits<T>: Freeze,
impl<T> RefUnwindSafe for ResourceMonitor<T>where
ResourceUsage<T>: RefUnwindSafe,
VecDeque<ResourceUsageSnapshot<T>>: RefUnwindSafe,
ResourceLimits<T>: RefUnwindSafe,
impl<T> Send for ResourceMonitor<T>
impl<T> Sync for ResourceMonitor<T>
impl<T> Unpin for ResourceMonitor<T>
impl<T> UnsafeUnpin for ResourceMonitor<T>where
ResourceUsage<T>: UnsafeUnpin,
VecDeque<ResourceUsageSnapshot<T>>: UnsafeUnpin,
ResourceLimits<T>: UnsafeUnpin,
impl<T> UnwindSafe for ResourceMonitor<T>where
ResourceUsage<T>: UnwindSafe,
VecDeque<ResourceUsageSnapshot<T>>: UnwindSafe,
ResourceLimits<T>: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more