Skip to main content

ArenaPool

Struct ArenaPool 

Source
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

Source

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).

Source

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.

Source

pub fn cap_per_arena(&self) -> usize

Capacity of each arena buffer this pool hands out, in bytes.

Source

pub fn max_arenas(&self) -> usize

Maximum number of arenas that may be checked out at once.

Source

pub fn lease(self: &Arc<Self>) -> Result<Arena>

Lease one arena from the pool. Returns Error::ResourceExhausted if every arena slot is already checked out by an Arena (or a Frame holding one).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.