Skip to main content

PagedArena

Struct PagedArena 

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

A fixed-capacity page allocator with deterministic first-fit placement.

Implementations§

Source§

impl PagedArena

Source

pub fn new(page_size: u64, page_count: u32) -> Result<Self, ArenaError>

Reserves all allocator metadata up front.

§Errors

Returns ArenaError::InvalidConfiguration for an empty arena.

Source

pub fn allocate(&mut self, byte_len: u64) -> Result<ArenaAllocation, ArenaError>

Reserves the first address-ordered run large enough for byte_len.

§Errors

Empty, overflowing and unsatisfied requests are returned as values.

Source

pub fn release(&mut self, allocation: ArenaAllocation) -> Result<(), ArenaError>

Releases a live allocation and coalesces adjacent free runs.

§Errors

Returns ArenaError::StaleAllocation when generation or extent no longer matches the arena.

Source

pub fn grow(&mut self, additional_pages: u32) -> Result<(), ArenaError>

Appends free pages without moving any live allocation.

Existing byte offsets remain stable, allowing a physical owner to copy the old address space verbatim into a larger GPU buffer.

§Errors

Zero growth and page-count overflow are rejected as typed values.

Source

pub const fn metrics(&self) -> ArenaMetrics

Current cumulative counters.

Source

pub fn capacity_bytes(&self) -> u64

Total bytes represented by the arena.

Source

pub fn page_count(&self) -> u32

Number of addressable pages.

Trait Implementations§

Source§

impl Debug for PagedArena

Source§

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

Formats the value using the given formatter. Read more

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 = !

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.