pub trait Pool {
type Data: 'static;
// Provided methods
fn alloc() -> Option<Box<Self, Uninit>>
where Self: Sized { ... }
fn grow(memory: &'static mut [u8]) -> usize { ... }
fn grow_exact<A>(memory: &'static mut MaybeUninit<A>) -> usize
where A: AsMut<[Node<Self::Data>]> { ... }
}
Expand description
A global singleton memory pool
Required Associated Types§
Provided Methods§
sourcefn alloc() -> Option<Box<Self, Uninit>>where
Self: Sized,
fn alloc() -> Option<Box<Self, Uninit>>where
Self: Sized,
Claims a memory block from the pool
Returns None
when the pool is observed as exhausted
NOTE: This method does not have bounded execution time; i.e. it contains a CAS loop
sourcefn grow(memory: &'static mut [u8]) -> usize
fn grow(memory: &'static mut [u8]) -> usize
Increases the capacity of the pool
This method might not fully utilize the given memory block due to alignment requirements
This method returns the number of new blocks that can be allocated.
sourcefn grow_exact<A>(memory: &'static mut MaybeUninit<A>) -> usize
fn grow_exact<A>(memory: &'static mut MaybeUninit<A>) -> usize
Increases the capacity of the pool
Unlike Pool.grow
this method fully utilizes the given
memory block
Object Safety§
This trait is not object safe.