[][src]Struct xalloc::ring::Ring

pub struct Ring<T> { /* fields omitted */ }

A dynamic external memory allocator providing the functionality of a circular buffer.

See the module-level documentation for more.

Type parameters

  • T is an integer type used to represent region sizes. You usually use u32 or u64 for this.

Methods

impl<T: BinaryUInteger> Ring<T>[src]

pub fn new(size: T) -> Self[src]

Construct a RingRegion.

size must be smaller than T::max_value() >> 1 (this is a precaution taken not to cause unintentional overflows).

pub fn is_empty(&self) -> bool[src]

Return true if Ring has no allocated regions.

pub fn is_full(&self) -> bool[src]

Return true if Ring has no free space.

pub fn alloc_back(&mut self, size: T) -> Option<(RingRegion<T>, T)>[src]

Allocate a region of the size size to the back of the allocated region.

Returns a handle of the allocated region and its offset if the allocation succeeds. Returns None otherwise.

size must not be zero.

pub fn alloc_front(&mut self, size: T) -> Option<(RingRegion<T>, T)>[src]

Allocate a region of the size size to the front of the allocated region.

Returns a handle of the allocated region and its offset if the allocation succeeds. Returns None otherwise.

size must not be zero.

pub fn alloc_back_aligned(
    &mut self,
    size: T,
    align: T
) -> Option<(RingRegion<T>, T)>
[src]

Allocate a region of the size size with a given alignment requirement to the back of the allocated region.

Returns a handle of the allocated region and its offset if the allocation succeeds. Returns None otherwise.

  • align must be a power of two.
  • size must not be zero.

pub fn alloc_front_aligned(
    &mut self,
    size: T,
    align: T
) -> Option<(RingRegion<T>, T)>
[src]

Allocate a region of the size size with a given alignment requirement to the front of the allocated region.

Returns a handle of the allocated region and its offset if the allocation succeeds. Returns None otherwise.

  • align must be a power of two.
  • size must not be zero.

pub fn dealloc_front_until(&mut self, r: RingRegion<T>)[src]

Deallocate frontmost (first) regions until r becomes the new frontmost region. r is not removed.

r must be in Ring. Otherwise, Ring might enter an inconsistent state and/or panic, but does not cause an undefined behavior.

pub fn dealloc_back_until(&mut self, r: RingRegion<T>)[src]

Deallocate backmost (last) regions until r becomes the new backmost region. r is not removed.

r must be in Ring. Otherwise, Ring might enter an inconsistent state and/or panic, but does not cause an undefined behavior.

pub fn dealloc_front(&mut self, r: RingRegion<T>)[src]

Deallocate the frontmost (first) region.

r must be the current frontmost region of Ring. Otherwise, Ring might enter an inconsistent state and/or panic, but does not cause an undefined behavior.

pub fn dealloc_back(&mut self, r: RingRegion<T>)[src]

Deallocate the backmost (last) region.

r must be the current backmost region of Ring. Otherwise, Ring might enter an inconsistent state and/or panic, but does not cause an undefined behavior.

Trait Implementations

impl<T: Debug> Debug for Ring<T>[src]

Auto Trait Implementations

impl<T> Send for Ring<T> where
    T: Send

impl<T> Sync for Ring<T> where
    T: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.