Skip to main content

SimpleFirstFit

Struct SimpleFirstFit 

Source
pub struct SimpleFirstFit<StateElement, Element> { /* private fields */ }
Expand description

Simple first fit free block manager, always search free block from memory region head (no free block link list), slowest, lowest internal fragment, lowest code size, and only support single memory region(extend just ignored)

Implementations§

Source§

impl<StateElement, Element> SimpleFirstFit<StateElement, Element>

Source

pub const fn new() -> Self

Trait Implementations§

Source§

impl<StateElement, Element> Default for SimpleFirstFit<StateElement, Element>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<StateElement: PrimaryUInt, Element> FreeBlockManager for SimpleFirstFit<StateElement, Element>

Source§

const MAX_ELEMENT_COUNT: ElementCount<Self::StateElement, Self::Element> = ElementCount::MAX

max element count for single region, and is max allocable element count for single allocation, memory region will be splited (when enxtend or init) if region element count bigger than Self::MAX_ELEMENT_COUNT
Source§

type StateElement = StateElement

Block state element, block state exactually use 2 Self::StateElement, must ensure size_of::<Self::StateElement>() <= size_of::<usize>(), Read more
Source§

type Element = Element

Block element, block underlying is [Self::Element], block align >= align_of::<Self::Element>, block size is multiple of size_of::<Self::Element>(), must ensure size_of::<Self::Element>() % align_of::<Self::Element>() == 0 && align_of::<Self::Element>() >= 2 && size_of::<Self::Element>() != 0. bigger size_of::Self::Element lead to bigger internal fragmentation, but can manage bigger memory region with same Self::StateElement
Source§

type Node = ()

Free block node, manager store Self::Node at free block head, then block size always >= size_of::<Self::Node>()
Source§

fn address_range(&self) -> (usize, usize)

acceptable address range, default full aligned range, maybe changed after init
Source§

fn take_out( &mut self, element_count: ElementCount<Self::StateElement, Self::Element>, ) -> Option<NonNull<Self::Node>>

take out a free block (find and unregister)
Source§

unsafe fn register(&mut self, _: NonNull<Self::Node>)

register a node to pool, caller must ensure node is free and in memory region managed by this manager Read more
Source§

unsafe fn unregister(&mut self, _: NonNull<Self::Node>)

unregister a node from pool, caller must ensture node is in this pool Read more
Source§

unsafe fn init(&mut self, ptr: NonNull<Self::Element>)

init manager, must call once and only once before call any other method, default call register. caller must ensure block body in address range Read more
Source§

unsafe fn extend(&mut self, ptr: NonNull<Self::Element>)

extend with new anther memory region node, default call register, caller must ensure block body in address range Read more
Source§

fn after_allocate(&mut self, ptr: NonNull<u8>, layout: Layout)

called by allocator just before block return to user, usually used by monitor, default no-op
Source§

fn before_deallocate(&mut self, ptr: NonNull<u8>, layout: Layout)

called by allocator just before deallocate block, usually used by monitor, default no-op

Auto Trait Implementations§

§

impl<StateElement, Element> !Send for SimpleFirstFit<StateElement, Element>

§

impl<StateElement, Element> !Sync for SimpleFirstFit<StateElement, Element>

§

impl<StateElement, Element> Freeze for SimpleFirstFit<StateElement, Element>

§

impl<StateElement, Element> RefUnwindSafe for SimpleFirstFit<StateElement, Element>
where StateElement: RefUnwindSafe, Element: RefUnwindSafe,

§

impl<StateElement, Element> Unpin for SimpleFirstFit<StateElement, Element>
where StateElement: Unpin, Element: Unpin,

§

impl<StateElement, Element> UnsafeUnpin for SimpleFirstFit<StateElement, Element>

§

impl<StateElement, Element> UnwindSafe for SimpleFirstFit<StateElement, Element>
where StateElement: UnwindSafe, Element: UnwindSafe,

Blanket Implementations§

Source§

impl<T> AlignedRepr<T> for T

Source§

impl<T> AlterRepr<T> for T

Source§

const IS_SWEAP_BYTES: bool = false

Source§

fn from_std_repr(v: T) -> T

Source§

fn into_std_repr(src: T) -> T

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.