pub struct ResourceLimiter { /* private fields */ }
Expand description
Resource limiter and enforcement engine.
Implementations§
Source§impl ResourceLimiter
impl ResourceLimiter
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if resource limiting is enabled.
Sourcepub fn set_default_quota(&self, quota: ResourceQuota)
pub fn set_default_quota(&self, quota: ResourceQuota)
Set the default quota for new threads.
Sourcepub fn set_thread_quota(&self, thread_id: ThreadId, quota: ResourceQuota)
pub fn set_thread_quota(&self, thread_id: ThreadId, quota: ResourceQuota)
Set a custom quota for a specific thread.
Sourcepub fn register_thread(&self, thread_id: ThreadId)
pub fn register_thread(&self, thread_id: ThreadId)
Register a new thread for resource tracking.
Sourcepub fn unregister_thread(&self, thread_id: ThreadId)
pub fn unregister_thread(&self, thread_id: ThreadId)
Unregister a thread from resource tracking.
Sourcepub fn check_resource_limit(
&self,
thread_id: ThreadId,
resource_type: ResourceType,
requested_amount: u64,
) -> Result<(), ThreadError>
pub fn check_resource_limit( &self, thread_id: ThreadId, resource_type: ResourceType, requested_amount: u64, ) -> Result<(), ThreadError>
Check if a resource allocation would violate limits.
Sourcepub fn update_resource_usage(
&self,
thread_id: ThreadId,
resource_type: ResourceType,
new_value: u64,
)
pub fn update_resource_usage( &self, thread_id: ThreadId, resource_type: ResourceType, new_value: u64, )
Update resource usage for a thread.
Sourcepub fn set_violation_handler(&self, handler: fn(&LimitViolation))
pub fn set_violation_handler(&self, handler: fn(&LimitViolation))
Set violation handler callback.
Sourcepub fn get_violation_history(&self) -> Vec<LimitViolation>
pub fn get_violation_history(&self) -> Vec<LimitViolation>
Get recent violation history.
Sourcepub fn get_system_usage(&self) -> SystemResourceUsage
pub fn get_system_usage(&self) -> SystemResourceUsage
Get system resource usage summary.
Auto Trait Implementations§
impl !Freeze for ResourceLimiter
impl !RefUnwindSafe for ResourceLimiter
impl Send for ResourceLimiter
impl Sync for ResourceLimiter
impl Unpin for ResourceLimiter
impl UnwindSafe for ResourceLimiter
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