pub struct MemoryGovernor { /* private fields */ }Expand description
The central memory governor.
Thread-safe: all budget operations use atomics internally.
Implementations§
Source§impl MemoryGovernor
impl MemoryGovernor
Sourcepub fn new(config: GovernorConfig) -> Result<Self>
pub fn new(config: GovernorConfig) -> Result<Self>
Create a new governor with the given configuration.
Sourcepub fn try_reserve(&self, engine: EngineId, size: usize) -> Result<()>
pub fn try_reserve(&self, engine: EngineId, size: usize) -> Result<()>
Try to reserve size bytes for the given engine.
Returns Ok(()) if the reservation succeeded, or an error describing
why it was rejected.
Sourcepub fn release(&self, engine: EngineId, size: usize)
pub fn release(&self, engine: EngineId, size: usize)
Release size bytes back to the given engine’s budget.
Sourcepub fn budget(&self, engine: EngineId) -> Option<&Budget>
pub fn budget(&self, engine: EngineId) -> Option<&Budget>
Get the budget for a specific engine.
Sourcepub fn global_ceiling(&self) -> usize
pub fn global_ceiling(&self) -> usize
Get the global ceiling.
Sourcepub fn total_allocated(&self) -> usize
pub fn total_allocated(&self) -> usize
Total memory allocated across all engines.
Sourcepub fn global_utilization_percent(&self) -> u8
pub fn global_utilization_percent(&self) -> u8
Global utilization as a percentage (0-100).
Sourcepub fn engine_pressure(&self, engine: EngineId) -> PressureLevel
pub fn engine_pressure(&self, engine: EngineId) -> PressureLevel
Current pressure level for a specific engine.
Sourcepub fn global_pressure(&self) -> PressureLevel
pub fn global_pressure(&self) -> PressureLevel
Current global pressure level.
Sourcepub fn set_thresholds(&mut self, thresholds: PressureThresholds)
pub fn set_thresholds(&mut self, thresholds: PressureThresholds)
Set custom pressure thresholds.
Sourcepub fn snapshot(&self) -> Vec<EngineSnapshot>
pub fn snapshot(&self) -> Vec<EngineSnapshot>
Snapshot of all engine budget states (for metrics/debugging).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MemoryGovernor
impl RefUnwindSafe for MemoryGovernor
impl Send for MemoryGovernor
impl Sync for MemoryGovernor
impl Unpin for MemoryGovernor
impl UnsafeUnpin for MemoryGovernor
impl UnwindSafe for MemoryGovernor
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