pub struct BumpAllocator {
current_chunk: NonNull<Chunk>,
allocation_count: i32,
chunk_pool: Arc<ChunkPool>,
stats: Stats,
}
Expand description
A simple bump allocator, sub-allocating from fixed size chunks that are provided by a parent allocator.
If an allocation is larger than the chunk size, a chunk sufficiently large to contain the allocation is added.
Fields§
§current_chunk: NonNull<Chunk>
The chunk we are currently allocating from.
allocation_count: i32
For debugging.
chunk_pool: Arc<ChunkPool>
§stats: Stats
Implementations§
Source§impl BumpAllocator
impl BumpAllocator
pub fn new(chunk_pool: Arc<ChunkPool>) -> Self
pub fn get_stats(&mut self) -> Stats
pub fn reset_stats(&mut self)
pub fn allocate_item( &mut self, layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
pub fn deallocate_item(&mut self, ptr: NonNull<u8>, layout: Layout)
pub unsafe fn grow_item( &mut self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
pub unsafe fn shrink_item( &mut self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
fn alloc_chunk(&mut self, item_size: usize) -> Result<(), AllocError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BumpAllocator
impl RefUnwindSafe for BumpAllocator
impl !Send for BumpAllocator
impl !Sync for BumpAllocator
impl Unpin for BumpAllocator
impl UnwindSafe for BumpAllocator
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more