pub struct Ledger { /* private fields */ }Expand description
The tagged accounting itself. One process-global instance backs the engine
(crate::memory::ledger()); the type is public so the accounting is testable on its
own instance.
Implementations§
Source§impl Ledger
impl Ledger
Sourcepub fn add(&self, tag: MemTag, realm: Realm, bytes: u64)
pub fn add(&self, tag: MemTag, realm: Realm, bytes: u64)
Take on bytes under tag. For a subsystem that grows and shrinks in
increments; one that knows its total should set it instead.
Sourcepub fn release(&self, tag: MemTag, realm: Realm, bytes: u64)
pub fn release(&self, tag: MemTag, realm: Realm, bytes: u64)
Give up bytes under tag. Saturates at zero: a reporter that
double-releases should read as holding nothing, never as holding an
enormous amount.
Sourcepub fn set(&self, tag: MemTag, realm: Realm, bytes: u64)
pub fn set(&self, tag: MemTag, realm: Realm, bytes: u64)
Declare the tag’s whole holding. Idempotent, so a pool that recomputes its resident bytes each frame cannot drift the way paired add/release calls can.
Sourcepub fn set_budget(&self, tag: MemTag, realm: Realm, budget: Option<u64>)
pub fn set_budget(&self, tag: MemTag, realm: Realm, budget: Option<u64>)
The ceiling the tag is expected to stay under. None clears it.
Sourcepub fn usage(&self, tag: MemTag, realm: Realm) -> TagUsage
pub fn usage(&self, tag: MemTag, realm: Realm) -> TagUsage
Set (or clear, with None) the byte budget for one tag and realm.
Sourcepub fn snapshot(&self) -> LedgerSnapshot
pub fn snapshot(&self) -> LedgerSnapshot
One tag’s current usage in one realm.