Trait MemoryPool

pub trait MemoryPool<T>: Send + Sync
where T: Send + Sync + Default,
{ // Required methods fn allocate(&mut self) -> Result<T, NerveError>; fn deallocate(&mut self, item: T) -> Result<(), NerveError>; fn capacity(&self) -> usize; fn available(&self) -> usize; fn utilization(&self) -> f64; fn is_empty(&self) -> bool; fn is_full(&self) -> bool; }
Expand description

Memory pool interface

Required Methods§

fn allocate(&mut self) -> Result<T, NerveError>

Allocate an item from the pool

fn deallocate(&mut self, item: T) -> Result<(), NerveError>

Deallocate an item back to the pool

fn capacity(&self) -> usize

Get pool capacity

fn available(&self) -> usize

Get number of available items

fn utilization(&self) -> f64

Get pool utilization percentage

fn is_empty(&self) -> bool

Check if pool is empty

fn is_full(&self) -> bool

Check if pool is full

Implementors§