Trait drone_core::heap::Allocator
[−]
[src]
pub trait Allocator {
const POOL_COUNT: usize;
unsafe fn get_pool_unchecked<I>(&self, index: I) -> &I::Output
where
I: SliceIndex<[Pool]>;
unsafe fn get_pool_unchecked_mut<I>(&mut self, index: I) -> &mut I::Output
where
I: SliceIndex<[Pool]>;
unsafe fn init(&mut self, start: &mut usize) { ... }
fn binary_search<T: Fits>(&self, value: T) -> usize { ... }
}A lock-free allocator that composes multiple memory pools.
An Allocator maintains a sort-order of its pools, so they can be
effectively accessed with binary_search.
Associated Constants
const POOL_COUNT: usize
Number of memory pools.
Required Methods
unsafe fn get_pool_unchecked<I>(&self, index: I) -> &I::Output where
I: SliceIndex<[Pool]>,
I: SliceIndex<[Pool]>,
Returns a reference to a pool or subslice, without doing bounds checking.
unsafe fn get_pool_unchecked_mut<I>(&mut self, index: I) -> &mut I::Output where
I: SliceIndex<[Pool]>,
I: SliceIndex<[Pool]>,
Returns a mutable reference to a pool or subslice, without doing bounds checking.
Provided Methods
unsafe fn init(&mut self, start: &mut usize)
Initializes the pools with start address.
Safety
- Must be called no more than once.
- Must be called before using the allocator.
startmust be word-aligned.
fn binary_search<T: Fits>(&self, value: T) -> usize
Binary searches the pools for a least-sized one which fits value.