pub struct PoolAllocator { /* private fields */ }Implementations§
Source§impl PoolAllocator
impl PoolAllocator
pub fn number_of_buckets(&self) -> u32
pub fn bucket_size(&self) -> usize
pub fn size(&self) -> usize
pub fn start_address(&self) -> usize
pub fn max_alignment(&self) -> usize
Sourcepub unsafe fn deallocate_bucket(&self, ptr: NonNull<u8>)
pub unsafe fn deallocate_bucket(&self, ptr: NonNull<u8>)
Releases an previously allocated bucket of memory.
§Safety
ptrmust be allocated previously withPoolAllocator::allocate()orPoolAllocator::allocate_zeroed()
Sourcepub unsafe fn new_uninit(
bucket_layout: Layout,
ptr: NonNull<u8>,
size: usize,
) -> Self
pub unsafe fn new_uninit( bucket_layout: Layout, ptr: NonNull<u8>, size: usize, ) -> Self
§Safety
ptrmust point to a piece of memory of lengthsize- before any other method can be called
PoolAllocator::init()must be called once
Sourcepub unsafe fn init<Allocator: BaseAllocator>(
&mut self,
allocator: &Allocator,
) -> Result<(), AllocationError>
pub unsafe fn init<Allocator: BaseAllocator>( &mut self, allocator: &Allocator, ) -> Result<(), AllocationError>
§Safety
- must be called exactly once before any other method can be called
pub fn memory_size(bucket_layout: Layout, size: usize) -> usize
Trait Implementations§
Source§impl Allocator for PoolAllocator
impl Allocator for PoolAllocator
Source§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocationGrowError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocationGrowError>
always returns the input ptr on success but with an increased size
Source§unsafe fn shrink(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocationShrinkError>
unsafe fn shrink( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocationShrinkError>
Decreases the size of an previously allocated chunk of memory. If the size increases it
fails. Read more
Source§unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocationGrowError>
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocationGrowError>
Increases the size of an previously allocated chunk of memory or allocates a new chunk
with the provided properties. If the chunk can be resized only the difference in size
will be zeroed.
It returns a failure when the size decreases. Read more
Source§impl BaseAllocator for PoolAllocator
impl BaseAllocator for PoolAllocator
Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocationError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocationError>
Allocates a memory chunk with the properties provided in layout and either
returns a slice or an allocation error on failure.
Source§unsafe fn deallocate(&self, ptr: NonNull<u8>, _layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, _layout: Layout)
Releases an previously allocated chunk of memory. Read more
Source§fn allocate_zeroed(
&self,
layout: Layout,
) -> Result<NonNull<[u8]>, AllocationError>
fn allocate_zeroed( &self, layout: Layout, ) -> Result<NonNull<[u8]>, AllocationError>
Allocates a memory chunk with the properties provided in layout and zeroes the memory
On success it returns a slice or an allocation error on failure.
Auto Trait Implementations§
impl !Freeze for PoolAllocator
impl !RefUnwindSafe for PoolAllocator
impl Send for PoolAllocator
impl Sync for PoolAllocator
impl Unpin for PoolAllocator
impl UnwindSafe for PoolAllocator
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