Skip to main content

ResourceAccountant

Struct ResourceAccountant 

Source
pub struct ResourceAccountant { /* private fields */ }
Expand description

Low-overhead single-owner framework resource ownership accountant.

Implementations§

Source§

impl ResourceAccountant

Single-owner registration, fence-deferred release, owner destruction, and leak attribution for ResourceAccountant.

Source

pub fn register_resource( &mut self, owner: ResourceOwnerId, kind: TrackedResourceKind, handle_id: u64, byte_size: usize, retention: ResourceRetentionClass, )

Registers or updates a tracked resource under a single authoritative owner, deduplicating by (kind, handle_id).

§Arguments
  • &Self - Mutable resource accountant.
  • ResourceOwnerId - Single authoritative resource owner.
  • TrackedResourceKind - Resource category.
  • u64 - Unique resource handle identifier within kind.
  • usize - Estimated byte footprint.
  • ResourceRetentionClass - Initial retention classification.
Source

pub fn update_retention( &mut self, kind: TrackedResourceKind, handle_id: u64, retention: ResourceRetentionClass, retire_fence_id: u64, ) -> bool

Updates the retention classification and optional GPU retirement fence of an already-tracked resource.

§Arguments
  • &Self - Mutable resource accountant.
  • TrackedResourceKind - Resource category.
  • u64 - Resource handle identifier.
  • ResourceRetentionClass - Replacement retention class.
  • u64 - GPU fence required before release (0 when immediate).
§Returns
  • bool - true if the resource was found and updated.
Source

pub fn release_resource( &mut self, kind: TrackedResourceKind, handle_id: u64, ) -> bool

Removes a released resource from the live registry.

§Arguments
  • &Self - Mutable resource accountant.
  • TrackedResourceKind - Resource category.
  • u64 - Resource handle identifier.
§Returns
  • bool - true if the resource existed and was released.
Source

pub fn mark_owner_destroyed( &mut self, owner: ResourceOwnerId, now_ms: u64, retire_fence_id: u64, ) -> usize

Releases all non-GPU resources belonging to owner and transitions GPU resources awaiting retire_fence_id to PendingFenceRelease.

§Arguments
  • &Self - Mutable resource accountant.
  • ResourceOwnerId - Destroyed owner identifier.
  • u64 - Monotonic destruction timestamp in milliseconds.
  • u64 - GPU retirement fence identifier (0 if no GPU work references this owner).
§Returns
  • usize - Number of resources still remaining live under owner after marking destruction.
Source

pub fn complete_gpu_fence(&mut self, fence_id: u64) -> usize

Marks GPU submission fence_id complete and automatically releases PendingFenceRelease GPU resources whose fence finished.

§Arguments
  • &Self - Mutable resource accountant.
  • u64 - Completed monotonic GPU fence identifier.
§Returns
  • usize - Number of fence-deferred GPU resources released.
Source

pub fn set_page_counts( &mut self, active: usize, frozen: usize, evicted: usize, destroyed: u64, )

Updates the high-level page lifecycle phase counters reported in snapshots.

§Arguments
  • &Self - Mutable resource accountant.
  • usize - Active page count.
  • usize - Frozen page count.
  • usize - Evicted cold page snapshot count.
  • u64 - Cumulative destroyed page count.
Source

pub fn snapshot( &self, now_ms: u64, grace_period_ms: u64, ) -> ResourceAccountingSnapshot

Captures a structured ResourceAccountingSnapshot cleanly separating expected_retained from destroyed_owner.live_objects.

§Arguments
  • &Self - Resource accountant reference.
  • u64 - Current monotonic timestamp in milliseconds.
  • u64 - Grace period in milliseconds after owner destruction before classifying remaining live objects as leaks.
§Returns
  • ResourceAccountingSnapshot - Complete ownership and leak-attribution telemetry snapshot.
Source§

impl ResourceAccountant

Source

pub fn get_completed_gpu_fence_id(&self) -> u64

Source

pub fn get_pages_active(&self) -> usize

Source

pub fn get_mut_pages_active(&mut self) -> &mut usize

Source

pub fn set_pages_active(&mut self, val: usize) -> &mut Self

Source

pub fn get_pages_frozen(&self) -> usize

Source

pub fn get_mut_pages_frozen(&mut self) -> &mut usize

Source

pub fn set_pages_frozen(&mut self, val: usize) -> &mut Self

Source

pub fn get_pages_evicted(&self) -> usize

Source

pub fn get_mut_pages_evicted(&mut self) -> &mut usize

Source

pub fn set_pages_evicted(&mut self, val: usize) -> &mut Self

Source

pub fn get_pages_destroyed(&self) -> u64

Source

pub fn get_mut_pages_destroyed(&mut self) -> &mut u64

Source

pub fn set_pages_destroyed(&mut self, val: u64) -> &mut Self

Source

pub fn get_total_registrations(&self) -> u64

Source

pub fn get_total_releases(&self) -> u64

Trait Implementations§

Source§

impl Clone for ResourceAccountant

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResourceAccountant

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ResourceAccountant

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for ResourceAccountant

§

impl Freeze for ResourceAccountant
where *const u8 is !null: Freeze, PhantomData<((TrackedResourceKind, u64), TrackedResourceRecord)>: Freeze, PhantomData<(ResourceOwnerId, (u64, u64))>: Freeze,

§

impl Move for ResourceAccountant

§

impl RefUnwindSafe for ResourceAccountant

§

impl Send for ResourceAccountant
where RawTable<((TrackedResourceKind, u64), TrackedResourceRecord)>: Send, RawTable<(ResourceOwnerId, (u64, u64))>: Send,

§

impl Sync for ResourceAccountant
where RawTable<((TrackedResourceKind, u64), TrackedResourceRecord)>: Sync, RawTable<(ResourceOwnerId, (u64, u64))>: Sync,

§

impl Unpin for ResourceAccountant
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for ResourceAccountant

§

impl UnwindSafe for ResourceAccountant

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.