[−][src]Struct slabmalloc::SCAllocator
A slab allocator allocates elements of a fixed size.
It has a 3 lists of ObjectPages from which it can allocate memory.
empty_slabs: Is a list of pages that the SCAllocator maintains, but has 0 allocations in them, these can be given back to a requestor in case of reclamation.slabs: A list of pages partially allocated and still have room for more.full_slabs: A list of pages that are completely allocated.
On allocation we allocate memory from slabs, however if the list is empty
we try to reclaim a page from empty_slabs before we return with an out-of-memory
error. If a page becomes full after the allocation we move it from slabs to
full_slabs.
Similarly, on dealloaction we might move a page from full_slabs to slabs
or from slabs to empty_slabs after we deallocated an object.
Methods
impl<'a> SCAllocator<'a>[src]
pub const fn new(size: usize) -> SCAllocator<'a>[src]
Create a new SCAllocator.
pub fn size(&self) -> usize[src]
Return object size of this allocator.
pub unsafe fn refill(&mut self, page: &'a mut ObjectPage<'a>)[src]
pub fn allocate(
&mut self,
layout: Layout
) -> Result<NonNull<u8>, AllocationError>[src]
&mut self,
layout: Layout
) -> Result<NonNull<u8>, AllocationError>
Allocates a block of memory with respect to alignment.
In case of failure will try to grow the slab allocator by requesting additional pages and re-try the allocation once more before we give up.
pub fn deallocate(
&mut self,
ptr: NonNull<u8>,
layout: Layout
) -> Result<(), AllocationError>[src]
&mut self,
ptr: NonNull<u8>,
layout: Layout
) -> Result<(), AllocationError>
Deallocates a previously allocated block.
Auto Trait Implementations
impl<'a> Unpin for SCAllocator<'a>
impl<'a> Send for SCAllocator<'a>
impl<'a> Sync for SCAllocator<'a>
impl<'a> !UnwindSafe for SCAllocator<'a>
impl<'a> RefUnwindSafe for SCAllocator<'a>
Blanket Implementations
impl<T> From<T> for T[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,