[][src]Struct context_allocator::allocators::MultipleBinarySearchTreeAllocator

pub struct MultipleBinarySearchTreeAllocator<MS: MemorySource> { /* fields omitted */ }

An allocator which uses sorted lists (red-black binary search trees) of different block sizes (sizes are powers of 2); in that sense, it is similar to an efficient buddy allocator.

However, it can also coalesce blocks that aren't a buddy, and, because of the way it uses block pointers, it can very efficiently find them; it has no book-keeping for allocated nodes whatsoever, at the expense of requiring the minimum allocated block size to be 32 bytes.

It currently has a hard maximum allocation size of 2^(log2(32) + 15) => 1Mb. It could be modified to make 'oversize' allocations out of multiple blocks, but its lack of book-keeping prevents them being deallocated. In the event that a large allocation is required, it is probably better to use mmap() or a NUMA mmap().

What it does not do is make an allocation out of differently sized blocks, eg a 96b allocation uses 128b, rather than 64b + maybe a coalesced 32b block. Whilst is could be modified to make such allocations, its lack of book-keeping prevents them being deallocated.

This allocator NEVER grows or shrinks its memory region.

This allocator is not thread-safe.

Methods

impl<MS: MemorySource> MultipleBinarySearchTreeAllocator<MS>[src]

pub fn new(
    memory_source: MS,
    memory_source_size: NonZeroUsize
) -> Result<Self, AllocErr>
[src]

If the provided memory's length is not a multiple of 2, then the remainder is unused.

The provided memory must be at least as long as the minimum block size.

The memory must be aligned to BinarySearchTreesWithCachedKnowledgeOfFirstChild::MinimumAlignment, which is the same as the size of a Node.

Trait Implementations

impl<MS: MemorySource> LocalAllocator for MultipleBinarySearchTreeAllocator<MS>[src]

fn contains(&self, from_memory_address: MemoryAddress) -> bool[src]

Returns true if this allocator is responsible for an allocation starting with the given from_memory_address. Read more

impl<MS: MemorySource> Allocator for MultipleBinarySearchTreeAllocator<MS>[src]

const ZeroSizedAllocation: MemoryAddress[src]

The sentinel value used for a zero-sized allocation.

fn adapt<'a>(&'a self) -> AllocatorAdaptor<'a, Self>[src]

Adapts to a GlobalAlloc and Alloc.

fn adapt_reference<'a>(&'a self) -> &'a AllocatorAdaptor<'a, Self>[src]

Adapts a reference to a GlobalAlloc and Alloc reference.

impl<MS: MemorySource> Drop for MultipleBinarySearchTreeAllocator<MS>[src]

impl<MS: MemorySource> Debug for MultipleBinarySearchTreeAllocator<MS>[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.