[][src]Struct bulk_allocator::BulkAllocator

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

BulkAllocator pools allocated memory and frees it on the destruction.

alloc() delegates the request to the backend if the requested layout is too large to cache; otherwise, it dispatches the pooled memory and return. If no memory is pooled, acquire memory chunk from the backend.

dealloc() delegates the request to the backend if the requested layout is too large to cache; otherwise, it pools the passed memory.

If the argument layout of alloc() is always same, probably LayoutBulkAllocator is better than BulkAllocator.

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.

Trait Implementations

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

Thread safety

All the methods are thread unsafe.

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

fn default() -> Self[src]

The backend is constructed by Default::default() and the new instance owns it.

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

impl<'a, B> From<&'a mut B> for BulkAllocator<'a, B> where
    B: 'a + AllocRef
[src]

fn from(backend: &'a mut B) -> Self[src]

The new instance borrows the backend and the lifetime is limited by it.

impl<B: AllocRef> From<B> for BulkAllocator<'static, B>[src]

fn from(backend: B) -> Self[src]

The new instance owns the backend.

Auto Trait Implementations

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

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

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

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

impl<'a, B> !UnwindSafe for BulkAllocator<'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<!> for T[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.