pub struct Ledger { /* private fields */ }Expand description
The tagged accounting itself. One process-global instance backs the engine
(crate::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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Ledger
impl RefUnwindSafe for Ledger
impl Send for Ledger
impl Sync for Ledger
impl Unpin for Ledger
impl UnsafeUnpin for Ledger
impl UnwindSafe for Ledger
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