pub struct SlabCache { /* private fields */ }Expand description
Slab cache for objects of a specific size
Implementations§
Source§impl SlabCache
impl SlabCache
pub fn new(object_size: usize, config: CacheConfig) -> Self
Sourcepub fn allocate(
&mut self,
memory_pool: &mut MemoryPool,
) -> Result<NonNull<u8>, SlabError>
pub fn allocate( &mut self, memory_pool: &mut MemoryPool, ) -> Result<NonNull<u8>, SlabError>
Allocate an object from this cache
Sourcepub fn deallocate(&mut self, ptr: NonNull<u8>) -> Result<(), SlabError>
pub fn deallocate(&mut self, ptr: NonNull<u8>) -> Result<(), SlabError>
Deallocate an object back to this cache
Sourcepub fn get_stats(&self) -> &CacheStats
pub fn get_stats(&self) -> &CacheStats
Get cache statistics
Sourcepub fn get_cache_info(&self) -> CacheInfo
pub fn get_cache_info(&self) -> CacheInfo
Get detailed cache information
Sourcepub fn reclaim_empty_slabs(&mut self, memory_pool: &mut MemoryPool) -> usize
pub fn reclaim_empty_slabs(&mut self, memory_pool: &mut MemoryPool) -> usize
Reclaim empty slabs
Auto Trait Implementations§
impl Freeze for SlabCache
impl RefUnwindSafe for SlabCache
impl !Send for SlabCache
impl !Sync for SlabCache
impl Unpin for SlabCache
impl UnsafeUnpin for SlabCache
impl UnwindSafe for SlabCache
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