[−][src]Struct swim_mem::alloc::Pool
Linear allocator for a dynamically growable set of memory blocks.
A Pool
allocates space in a sequence of linear memory Pack
s allocated
by a Heap
. Pools only reclaim space when the most recent allocation drops,
and when the whole pool drops. To free a pool, use IntoHold
to move live
values to another hold, then drop the pool.
Methods
impl<'a> Pool<'a>
[src]
pub fn new(heap: &'a dyn Heap<'a>) -> Pool<'a>
[src]
Returns a new Pool
that allocates memory from the given heap
.
pub fn heap(&self) -> &'a dyn Heap<'a>
[src]
Returns the Heap
used to allocate memory for the internal pack list.
pub fn size(&self) -> usize
[src]
Returns the number of reserved bytes in this Pool
.
pub fn live(&self) -> usize
[src]
Return the number of live allocations in this Pool
.
pub fn used(&self) -> usize
[src]
Returns the number of bytes currently allocated in this Pool
.
Trait Implementations
impl<'a> Hold<'a> for Pool<'a>
[src]
unsafe fn alloc(&self, layout: Layout) -> Result<Block<'a>, HoldError>
[src]
unsafe fn dealloc(&self, _block: Block<'a>) -> usize
[src]
unsafe fn resize(
&self,
_block: Block<'a>,
_layout: Layout
) -> Result<Block<'a>, HoldError>
[src]
&self,
_block: Block<'a>,
_layout: Layout
) -> Result<Block<'a>, HoldError>
unsafe fn realloc(
&self,
block: Block<'a>,
layout: Layout
) -> Result<Block<'a>, HoldError>
[src]
&self,
block: Block<'a>,
layout: Layout
) -> Result<Block<'a>, HoldError>
Attempts to resize a memory block
allocated by this Hold
to fit a new layout
. Returns Ok
with the resized memory block on success; returns a HoldError
on failure. Read more
impl<'a> Drop for Pool<'a>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> TryFrom 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 for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,