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§
Sourcefn alloc(&self, n: usize) -> Result<Mem::FSliceMut<'_>, Error>
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 ofMem::ALIGNMENT