pub struct Arena { /* private fields */ }Expand description
A single epoch’s memory arena.
Allocates by bumping a pointer forward - extremely fast. You can’t free individual allocations; instead, drop the whole arena when the epoch is no longer needed.
Thread-safe: multiple threads can allocate concurrently using atomics.
Implementations§
Source§impl Arena
impl Arena
Sourcepub fn with_chunk_size(epoch: EpochId, chunk_size: usize) -> Self
pub fn with_chunk_size(epoch: EpochId, chunk_size: usize) -> Self
Creates a new arena with a custom chunk size.
Sourcepub fn alloc_value<T>(&self, value: T) -> &mut T
pub fn alloc_value<T>(&self, value: T) -> &mut T
Allocates a value of type T.
Sourcepub fn alloc_slice<T: Copy>(&self, values: &[T]) -> &mut [T]
pub fn alloc_slice<T: Copy>(&self, values: &[T]) -> &mut [T]
Allocates a slice of values.
Sourcepub fn total_allocated(&self) -> usize
pub fn total_allocated(&self) -> usize
Returns the total memory allocated by this arena.
Sourcepub fn total_used(&self) -> usize
pub fn total_used(&self) -> usize
Returns the total memory used (not just allocated capacity).
Sourcepub fn stats(&self) -> ArenaStats
pub fn stats(&self) -> ArenaStats
Returns statistics about this arena.
Auto Trait Implementations§
impl !Freeze for Arena
impl !RefUnwindSafe for Arena
impl Send for Arena
impl Sync for Arena
impl Unpin for Arena
impl UnwindSafe for Arena
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