Trait ComputeAllocator

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

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 capacity(&self) -> usize

Returns the remaining number of elements that can be allocated.

Source

fn subscope_allocator(&mut self) -> impl ComputeAllocator<F, Mem>

Returns the remaining unallocated capacity as a new allocator with a limited scope.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

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