pub struct ArenaPool { /* private fields */ }Expand description
Send + Sync pool of reusable byte buffers for arena-backed frame
allocations. Mirrors crate::arena::ArenaPool in shape and
behaviour; the only difference is that the Arena (and the
Frame holding it) handed out are themselves Send + Sync.
Construct via ArenaPool::new. Lease an Arena per frame via
ArenaPool::lease; drop the arena (or drop the last clone of a
Frame holding it) to return its buffer to the pool.
Implementations§
Source§impl ArenaPool
impl ArenaPool
Sourcepub fn new(max_arenas: usize, cap_per_arena: usize) -> Arc<Self> ⓘ
pub fn new(max_arenas: usize, cap_per_arena: usize) -> Arc<Self> ⓘ
Construct a new pool with max_arenas buffer slots, each of
cap_per_arena bytes. Buffers are allocated lazily on first
lease — a freshly constructed pool holds no memory.
Per-arena allocation count is capped at a generous 1 M
(override via ArenaPool::with_alloc_count_cap).
Sourcepub fn with_alloc_count_cap(
max_arenas: usize,
cap_per_arena: usize,
max_alloc_count_per_arena: u32,
) -> Arc<Self> ⓘ
pub fn with_alloc_count_cap( max_arenas: usize, cap_per_arena: usize, max_alloc_count_per_arena: u32, ) -> Arc<Self> ⓘ
Like ArenaPool::new but lets the caller set the per-arena
allocation-count cap. Useful when the caller is plumbing
crate::DecoderLimits through.
Sourcepub fn cap_per_arena(&self) -> usize
pub fn cap_per_arena(&self) -> usize
Capacity of each arena buffer this pool hands out, in bytes.
Sourcepub fn max_arenas(&self) -> usize
pub fn max_arenas(&self) -> usize
Maximum number of arenas that may be checked out at once.