[][src]Trait drone_core::heap::Allocator

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]>
; fn alloc_hook(_layout: Layout, _pool: &Pool) { ... }
fn dealloc_hook(_layout: Layout, _pool: &Pool) { ... }
fn grow_in_place_hook(_layout: Layout, _new_size: usize) { ... }
fn shrink_in_place_hook(_layout: Layout, _new_size: usize) { ... }
fn binary_search<T: Fits>(&self, value: T) -> usize { ... } }

Allocator for a generic memory pools layout.

The trait is supposed to be implemented for an array of pools. heap macro should be used to generate the concrete type and the implementation.

Associated Constants

const POOL_COUNT: usize

The total number of memory pools.

Loading content...

Required methods

unsafe fn get_pool_unchecked<I>(&self, index: I) -> &I::Output where
    I: SliceIndex<[Pool]>, 

Returns a reference to a pool or subslice, without doing bounds checking.

Safety

Calling this method with an out-of-bounds index is Undefined Behavior.

unsafe fn get_pool_unchecked_mut<I>(&mut self, index: I) -> &mut I::Output where
    I: SliceIndex<[Pool]>, 

Returns a mutable reference to a pool or subslice, without doing bounds checking.

Safety

Calling this method with an out-of-bounds index is Undefined Behavior.

Loading content...

Provided methods

fn alloc_hook(_layout: Layout, _pool: &Pool)

Empty allocation hook. Can be re-defined by the implementation.

fn dealloc_hook(_layout: Layout, _pool: &Pool)

Empty deallocation hook. Can be re-defined by the implementation.

fn grow_in_place_hook(_layout: Layout, _new_size: usize)

Empty growing in place hook. Can be re-defined by the implementation.

fn shrink_in_place_hook(_layout: Layout, _new_size: usize)

Empty shrinking in place hook. Can be re-defined by the implementation.

Does a binary search for the pool with the smallest block size to fit value.

Loading content...

Implementors

Loading content...