heapdump_vmo::allocations_table_v1

Struct AllocationsTableWriter

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

Mediates write access to a VMO containing an hash table of allocated blocks indexed by block address.

All the updates happen atomically so that, at any time, snapshotting the VMO always results in a coherent snapshot of the table.

Hash collisions are handled by maintaining per-bucket linked lists. Specifically, an array of list heads, one for each bucket, is stored at the beginning of the VMO. The remaining part of the VMO contains the linked list nodes.

Implementations§

Source§

impl AllocationsTableWriter

Source

pub fn new(vmo: &Vmo) -> Result<AllocationsTableWriter, Error>

Initializes a VMO as an empty table and creates an AllocationsTableWriter to write into it.

§Safety

The caller must guarantee that the vmo is not accessed by others while the returned instance is alive.

Source

pub fn insert_allocation( &mut self, address: u64, size: u64, thread_info_key: ResourceKey, stack_trace_key: ResourceKey, timestamp: MonotonicInstant, ) -> Result<bool, Error>

Inserts a new entry in the hash table.

Returns Ok(true) if it has been inserted, Ok(false) if a previous entry with the same address already existed, or an error if no free nodes are available.

Source

pub fn erase_allocation(&mut self, address: u64) -> Option<u64>

Removes an entry from the hash table and returns the value of the removed entry’s size field.

Source

pub fn replace_allocation( &mut self, address: u64, size: u64, thread_info_key: ResourceKey, stack_trace_key: ResourceKey, timestamp: MonotonicInstant, ) -> Result<Option<u64>, Error>

Atomically updates metadata for the given address in the hash table.

Returns Ok(Some(old_size)) if it has been updated, Ok(None) if no entry with the given address exists, or an error if no free nodes are available.

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.