pub struct LinearAllocator<B: Backend> { /* private fields */ }
Expand description
Linear allocator that return memory from chunk sequentially. It keeps only number of bytes allocated from each chunk. Once chunk is exhausted it is placed into list. When all blocks allocated from head of that list are freed, head is freed as well.
This allocator suites best short-lived types of allocations. Allocation strategy requires minimal overhead and implementation is fast. But holding single block will completely stop memory recycling.
Implementations§
Source§impl<B> LinearAllocator<B>where
B: Backend,
impl<B> LinearAllocator<B>where
B: Backend,
Sourcepub fn properties_required() -> Properties
pub fn properties_required() -> Properties
Get properties required by the LinearAllocator
.
Sourcepub fn max_allocation(&self) -> u64
pub fn max_allocation(&self) -> u64
Maximum allocation size.
Sourcepub fn new(
memory_type: MemoryTypeId,
memory_properties: Properties,
config: LinearConfig,
) -> Self
pub fn new( memory_type: MemoryTypeId, memory_properties: Properties, config: LinearConfig, ) -> Self
Create new LinearAllocator
for memory_type
with memory_properties
specified,
with LinearConfig
provided.
Trait Implementations§
Source§impl<B> Allocator<B> for LinearAllocator<B>where
B: Backend,
impl<B> Allocator<B> for LinearAllocator<B>where
B: Backend,
Source§type Block = LinearBlock<B>
type Block = LinearBlock<B>
Block type returned by allocator.
Source§fn alloc(
&mut self,
device: &B::Device,
size: u64,
align: u64,
) -> Result<(LinearBlock<B>, u64), AllocationError>
fn alloc( &mut self, device: &B::Device, size: u64, align: u64, ) -> Result<(LinearBlock<B>, u64), AllocationError>
Allocate block of memory.
On success returns allocated block and amount of memory consumed from device.
Auto Trait Implementations§
impl<B> Freeze for LinearAllocator<B>
impl<B> RefUnwindSafe for LinearAllocator<B>
impl<B> Send for LinearAllocator<B>
impl<B> Sync for LinearAllocator<B>
impl<B> Unpin for LinearAllocator<B>
impl<B> UnwindSafe for LinearAllocator<B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more