Struct heapless::pool::Pool

source ·
pub struct Pool<T> { /* private fields */ }
Expand description

A lock-free memory pool

Implementations§

source§

impl<T> Pool<T>

source

pub const fn new() -> Self

Creates a new empty pool

source

pub fn alloc(&self) -> Option<Box<T, Uninit>>

Claims a memory block from the pool

Returns None when the pool is observed as exhausted

NOTE: This method does not have bounded execution time because it contains a CAS loop

source

pub fn free<S>(&self, value: Box<T, S>)
where S: 'static,

Returns a memory block to the pool

NOTE: T’s destructor (if any) will run on value iff S = Init

NOTE: This method does not have bounded execution time because it contains a CAS loop

source

pub fn grow(&self, memory: &'static mut [u8]) -> usize

Increases the capacity of the pool

This method might not fully utilize the given memory block due to alignment requirements.

This method returns the number of new blocks that can be allocated.

source

pub fn grow_exact<A>(&self, memory: &'static mut MaybeUninit<A>) -> usize
where A: AsMut<[Node<T>]>,

Increases the capacity of the pool

Unlike Pool.grow this method fully utilizes the given memory block

Trait Implementations§

source§

impl<T> Send for Pool<T>

Auto Trait Implementations§

§

impl<T> !Freeze for Pool<T>

§

impl<T> !RefUnwindSafe for Pool<T>

§

impl<T> !Sync for Pool<T>

§

impl<T> Unpin for Pool<T>

§

impl<T> !UnwindSafe for Pool<T>

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>,

§

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>,

§

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.