Trait ComputeAllocator

Source
pub trait ComputeAllocator<F, Mem: ComputeMemory<F>> {
    // Required methods
    fn alloc(&self, n: usize) -> Result<Mem::FSliceMut<'_>, Error>;
    fn remaining(&mut self) -> Mem::FSliceMut<'_>;
    fn capacity(&self) -> usize;
}

Required Methods§

Source

fn alloc(&self, n: usize) -> Result<Mem::FSliceMut<'_>, Error>

Allocates a slice of elements.

This method operates on an immutable self reference so that multiple allocator references can co-exist. This follows how the bumpalo crate’s Bump interface works. It may not be necessary actually (since this partitions a borrowed slice, whereas Bump owns its memory).

§Pre-conditions
  • n must be a multiple of Mem::ALIGNMENT
Source

fn remaining(&mut self) -> Mem::FSliceMut<'_>

Borrow the remaining unallocated capacity.

This allows another allocator to have unique mutable access to the rest of the elements in this allocator until it gets dropped, at which point this allocator can be used again

Source

fn capacity(&self) -> usize

Returns the remaining number of elements that can be allocated.

Implementors§

Source§

impl<'a, F, Mem: ComputeMemory<F>> ComputeAllocator<F, Mem> for BumpAllocator<'a, F, Mem>