Struct rlsf::FlexTlsf

source ·
pub struct FlexTlsf<Source: FlexSource, FLBitmap, SLBitmap, const FLLEN: usize, const SLLEN: usize> { /* private fields */ }
Expand description

A wrapper of Tlsf that automatically acquires fresh memory pools from FlexSource.

Implementations§

source§

impl<Source: FlexSource, FLBitmap: BinInteger, SLBitmap: BinInteger, const FLLEN: usize, const SLLEN: usize> FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>

source

pub const fn new(source: Source) -> Self

Construct a new FlexTlsf object.

source

pub fn source_ref(&self) -> &Source

Borrow the contained Source.

source

pub unsafe fn source_mut_unchecked(&mut self) -> &mut Source

Mutably borrow the contained Source.

Safety

The caller must not replace the Source with another one or modify any existing allocations in the Source.

source

pub fn allocate(&mut self, layout: Layout) -> Option<NonNull<u8>>

Attempt to allocate a block of memory.

Returns the starting address of the allocated memory block on success; None otherwise.

Time Complexity

This method will complete in constant time (assuming Source’s methods do so as well).

source

pub unsafe fn deallocate(&mut self, ptr: NonNull<u8>, align: usize)

Deallocate a previously allocated memory block.

Time Complexity

This method will complete in constant time (assuming Source’s methods do so as well).

Safety
  • ptr must denote a memory block previously allocated via self.
  • The memory block must have been allocated with the same alignment (Layout::align) as align.
source

pub unsafe fn allocation_usable_size(ptr: NonNull<u8>) -> usize

Available on crate feature unstable only.

Get the actual usable size of a previously allocated memory block.

Safety
  • ptr must denote a memory block previously allocated via some instance of Self.
  • The call must happen-before the deallocation or reallocation of the memory block.
source

pub unsafe fn reallocate( &mut self, ptr: NonNull<u8>, new_layout: Layout ) -> Option<NonNull<u8>>

Shrink or grow a previously allocated memory block.

Returns the new starting address of the memory block on success; None otherwise.

Time Complexity

Unlike other methods, this method will complete in linear time (O(old_size)), assuming Source’s methods do so as well.

Safety
  • ptr must denote a memory block previously allocated via self.
  • The memory block must have been allocated with the same alignment (Layout::align) as new_layout.

Trait Implementations§

source§

impl<Source: FlexSource + ConstDefault, FLBitmap: BinInteger, SLBitmap: BinInteger, const FLLEN: usize, const SLLEN: usize> ConstDefault for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>

Initialization with a FlexSource provided by ConstDefault::DEFAULT

source§

const DEFAULT: Self = _

An empty pool.

source§

impl<Source: Debug + FlexSource, FLBitmap: Debug, SLBitmap: Debug, const FLLEN: usize, const SLLEN: usize> Debug for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Source: FlexSource + Default, FLBitmap: BinInteger, SLBitmap: BinInteger, const FLLEN: usize, const SLLEN: usize> Default for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>

Initialization with a FlexSource provided by Default::default

source§

fn default() -> Self

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

impl<Source: FlexSource, FLBitmap, SLBitmap, const FLLEN: usize, const SLLEN: usize> Drop for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<Source, FLBitmap, SLBitmap, const FLLEN: usize, const SLLEN: usize> RefUnwindSafe for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>where FLBitmap: RefUnwindSafe, SLBitmap: RefUnwindSafe, Source: RefUnwindSafe,

§

impl<Source, FLBitmap, SLBitmap, const FLLEN: usize, const SLLEN: usize> Send for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>where Source: Send,

§

impl<Source, FLBitmap, SLBitmap, const FLLEN: usize, const SLLEN: usize> Sync for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>where Source: Sync,

§

impl<Source, FLBitmap, SLBitmap, const FLLEN: usize, const SLLEN: usize> Unpin for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>where FLBitmap: Unpin, SLBitmap: Unpin, Source: Unpin,

§

impl<Source, FLBitmap, SLBitmap, const FLLEN: usize, const SLLEN: usize> UnwindSafe for FlexTlsf<Source, FLBitmap, SLBitmap, FLLEN, SLLEN>where FLBitmap: UnwindSafe, SLBitmap: UnwindSafe, Source: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.