pub struct ResourceGovernor { /* private fields */ }Expand description
Tracks and enforces resource limits for the browser pool.
Implementations§
Source§impl ResourceGovernor
impl ResourceGovernor
Sourcepub fn new(memory_limit_mb: u64, request_timeout_ms: u64) -> Self
pub fn new(memory_limit_mb: u64, request_timeout_ms: u64) -> Self
Create a new resource governor with a memory limit in megabytes.
Sourcepub fn can_acquire(&self, estimated_mb: u64) -> bool
pub fn can_acquire(&self, estimated_mb: u64) -> bool
Check if acquiring another context would exceed the memory limit.
Sourcepub fn record_allocation(&self, bytes: u64)
pub fn record_allocation(&self, bytes: u64)
Record memory allocation for a context.
Sourcepub fn record_deallocation(&self, bytes: u64)
pub fn record_deallocation(&self, bytes: u64)
Record memory deallocation when a context is released.
Sourcepub fn memory_usage_bytes(&self) -> u64
pub fn memory_usage_bytes(&self) -> u64
Current memory usage in bytes.
Sourcepub fn memory_usage_mb(&self) -> f64
pub fn memory_usage_mb(&self) -> f64
Current memory usage in megabytes.
Sourcepub fn request_timeout_ms(&self) -> u64
pub fn request_timeout_ms(&self) -> u64
Per-request timeout in milliseconds.
Sourcepub fn memory_limit_mb(&self) -> u64
pub fn memory_limit_mb(&self) -> u64
Memory limit in megabytes.
Auto Trait Implementations§
impl Freeze for ResourceGovernor
impl RefUnwindSafe for ResourceGovernor
impl Send for ResourceGovernor
impl Sync for ResourceGovernor
impl Unpin for ResourceGovernor
impl UnsafeUnpin for ResourceGovernor
impl UnwindSafe for ResourceGovernor
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