pub struct Arena { /* private fields */ }Expand description
A bump allocator over one fixed reservation, reset as a whole.
Implementations§
Source§impl Arena
impl Arena
Sourcepub fn with_capacity(bytes: usize) -> Arena
pub fn with_capacity(bytes: usize) -> Arena
Reserve bytes up front. The buffer is taken from the global allocator
once and held until the arena drops; nothing here allocates again.
Sourcepub fn tagged(bytes: usize, tag: MemTag) -> Arena
pub fn tagged(bytes: usize, tag: MemTag) -> Arena
As with_capacity, reporting the reservation under tag in host memory
for as long as the arena lives. An arena’s whole cost is its reservation,
so it can account for itself rather than making its owner do it.
Sourcepub fn overflows(&self) -> u32
pub fn overflows(&self) -> u32
Requests declined since the last clear_overflows. Non-zero means
callers fell back to the heap and the reserve wants raising.
Sourcepub fn clear_overflows(&self)
pub fn clear_overflows(&self)
Reset the overflow counter.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Give back everything handed out. Taking &mut self is the safety
argument: no allocation from this arena can still be borrowed.
Deliberately leaves peak and overflows alone: both describe the worst
frame so far, which is what sizes the reserve, and a per-frame reset would
erase exactly the evidence they exist to carry.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Arena
impl !RefUnwindSafe for Arena
impl !Sync for Arena
impl Unpin for Arena
impl UnsafeUnpin for Arena
impl UnwindSafe for Arena
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more