Skip to main content

Allocator

Trait Allocator 

Source
pub trait Allocator {
    type Options;
    type Allocation<T>: Allocation<T>;

    // Required method
    fn allocate<T>(items: usize, options: Self::Options) -> Self::Allocation<T>;
}
Expand description

Backing allocator for the queue slot buffer.

Implementors are called once at construction, before any producer or consumer touches the returned memory, and are expected to hand back a contiguous, aligned region big enough to hold items cells.

Required Associated Types§

Source

type Options

Configuration passed to allocate. Each allocator defines its own options type (e.g. mlock toggle, hugepage size).

Source

type Allocation<T>: Allocation<T>

Allocation wrapper type returned by allocate.

Required Methods§

Source

fn allocate<T>(items: usize, options: Self::Options) -> Self::Allocation<T>

Allocates space for items cells of T.

The returned Allocation owns the memory and releases it on drop. The cells may be uninitialized; callers must write a cell before reading it.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§