pub struct SlabAllocator { /* private fields */ }Expand description
Slab allocator for fixed-size objects
Implementations§
Source§impl SlabAllocator
impl SlabAllocator
pub fn new(base_ptr: NonNull<u8>, total_size: usize, config: SlabConfig) -> Self
Sourcepub fn allocate(&mut self, size: usize) -> Result<NonNull<u8>, SlabError>
pub fn allocate(&mut self, size: usize) -> Result<NonNull<u8>, SlabError>
Allocate object of specified size
Sourcepub fn deallocate(
&mut self,
ptr: NonNull<u8>,
size: usize,
) -> Result<(), SlabError>
pub fn deallocate( &mut self, ptr: NonNull<u8>, size: usize, ) -> Result<(), SlabError>
Deallocate object
Sourcepub fn get_stats(&self) -> SlabAllocatorStats
pub fn get_stats(&self) -> SlabAllocatorStats
Get allocator statistics
Sourcepub fn get_all_cache_info(&self) -> Vec<(usize, CacheInfo)>
pub fn get_all_cache_info(&self) -> Vec<(usize, CacheInfo)>
Get information about all caches
Sourcepub fn reclaim_memory(&mut self) -> usize
pub fn reclaim_memory(&mut self) -> usize
Reclaim memory from empty slabs
Sourcepub fn destroy_cache(&mut self, size: usize) -> Result<(), SlabError>
pub fn destroy_cache(&mut self, size: usize) -> Result<(), SlabError>
Destroy cache for specific size
Sourcepub fn get_memory_usage(&self) -> MemoryPoolUsage
pub fn get_memory_usage(&self) -> MemoryPoolUsage
Get memory pool usage
Trait Implementations§
impl Send for SlabAllocator
impl Sync for SlabAllocator
Auto Trait Implementations§
impl Freeze for SlabAllocator
impl RefUnwindSafe for SlabAllocator
impl Unpin for SlabAllocator
impl UnwindSafe for SlabAllocator
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