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.