[][src]Struct bulk_allocator::LayoutBulkAllocator

pub struct LayoutBulkAllocator<'a, B: 'a + AllocRef> { /* fields omitted */ }

LayoutBulkAllocator pools allocated memory and frees it on the destruction.

alloc() and dealloc() delegates the request if the layout is different from what is specified to the constructor; otherwise, dealloc() caches the passed pointer and alloc() returns the cache. If no memory is pooled, alloc() allocate memory chunk from the backend, and makes caches at first.

Compared to BulkAllocator the performance of LayoutBulkAllocator is better than that of BulkAllocator as long as the argument layout of alloc() and dealloc() is same to which is passed to the constructor.

Lifetime

Each instance owns or borrows the backend AllocRef instance. If it is borrowed, the lifetime is limited by the reference; otherwise, the lifetime will be 'static.

Thread safety

All the mutable methods are thread unsafe.

Warnings

After drop, programer must NOT use the memories which method alloc() of this instance returned.

Implementations

impl<B> LayoutBulkAllocator<'static, B> where
    B: AllocRef + Default
[src]

pub fn from_layout(layout: Layout) -> Self[src]

Constructor specifies only the layout for the instance to use the cache.

The backend AllocRef instance is created by Default::default(). The instance owns the backend, so there is no limitation for the lifetime.

impl<B: AllocRef> LayoutBulkAllocator<'static, B>[src]

pub fn from_layout_backend(layout: Layout, backend: B) -> Self[src]

Construct a new instance from the layout and the backend AllocRef instance.

The instance owns the backend, so there is no limitation of the lifetime.

impl<'a, B: 'a + AllocRef> LayoutBulkAllocator<'a, B>[src]

pub fn from_layout_mut_backend(layout: Layout, backend: &'a mut B) -> Self[src]

Construct a neww instance from the layout and the reference to the backend.

The instance just borrows the backend, so the lifetime is limited.

Trait Implementations

impl<B: AllocRef, '_> AllocRef for LayoutBulkAllocator<'_, B>[src]

Thread safety

All the methods are thread unsafe.

impl<B: AllocRef, '_> Drop for LayoutBulkAllocator<'_, B>[src]

Auto Trait Implementations

impl<'a, B> RefUnwindSafe for LayoutBulkAllocator<'a, B> where
    B: RefUnwindSafe

impl<'a, B> !Send for LayoutBulkAllocator<'a, B>

impl<'a, B> !Sync for LayoutBulkAllocator<'a, B>

impl<'a, B> Unpin for LayoutBulkAllocator<'a, B> where
    B: Unpin

impl<'a, B> !UnwindSafe for LayoutBulkAllocator<'a, B>

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.