[−][src]Struct bulk_allocator::BulkAllocator
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.
fn alloc(
&mut self,
layout: Layout,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
[src]
&mut self,
layout: Layout,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout)
[src]
unsafe fn grow(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize,
placement: ReallocPlacement,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
[src]
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize,
placement: ReallocPlacement,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
unsafe fn shrink(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize,
placement: ReallocPlacement
) -> Result<MemoryBlock, AllocErr>
[src]
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize,
placement: ReallocPlacement
) -> Result<MemoryBlock, AllocErr>
fn by_ref(&mut self) -> &mut Self
[src]
impl<B> Default for BulkAllocator<'static, B> where
B: AllocRef + Default,
[src]
B: AllocRef + Default,
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]
B: 'a + AllocRef,
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]
Auto Trait Implementations
impl<'a, B> RefUnwindSafe for BulkAllocator<'a, B> where
B: RefUnwindSafe,
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,
B: Unpin,
impl<'a, B> !UnwindSafe for BulkAllocator<'a, B>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[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]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,