slab_allocator::slab

Struct FreeList

Source
struct FreeList {
    len: usize,
    head: Option<&'static mut FreeBlock>,
}
Expand description

内存块空闲列表

Fields§

§len: usize

空闲列表的长度

§head: Option<&'static mut FreeBlock>

空闲列表的头部节点

Implementations§

Source§

impl FreeList

Source

pub const fn empty() -> Self

建立一个新的空闲列表

Source

pub fn new(start: Address, block_size: usize, block_num: usize) -> Self

建立一个新的空闲列表,其中包含指定数量的空闲块。

§参数
  • start:内存块的起始地址
  • block_size:每个内存块的大小
  • block_num:内存块的数量
§返回

具有指定参数的新 FreeList 实例。

Source

pub fn push(&mut self, free_block: &'static mut FreeBlock)

将一个空闲块推入空闲列表。

§参数
  • free_block:要添加到列表中的空闲块的可变引用。
Source

pub fn pop(&mut self) -> Option<&'static mut FreeBlock>

从空闲列表中弹出一个空闲块。

§返回

如果列表不为空,则包含对空闲块的可变引用的 Option,如果列表为空,则返回 None。

Trait Implementations§

Source§

impl Drop for FreeList

为 FreeList 实现 Drop 特性,以便在 FreeList 被销毁时释放所有节点。

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

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.