Trait MemoryPool
pub trait MemoryPool<T>: Send + Sync{
// 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>
fn allocate(&mut self) -> Result<T, NerveError>
Allocate an item from the pool
fn deallocate(&mut self, item: T) -> Result<(), NerveError>
fn deallocate(&mut self, item: T) -> Result<(), NerveError>
Deallocate an item back to the pool
fn utilization(&self) -> f64
fn utilization(&self) -> f64
Get pool utilization percentage