pub struct Pool { /* private fields */ }Expand description
A shared byte budget that caches charge into; cloning shares the same budget.
The pool tracks how many payload bytes are cached across every registered group, plus the mean last-access time of the evictable ones. It never evicts on its own: tracks accrue eviction debt as they write and evict their own oldest groups to pay it, so every operation here is a few atomics with no lock. The capacity is therefore a target usage converges toward, not a hard limit: carried debt, capped payments, and the always-protected live edge all let usage transiently exceed it.
Implementations§
Source§impl Pool
impl Pool
Sourcepub fn new(capacity: u64) -> Self
pub fn new(capacity: u64) -> Self
Create a pool with a byte target that tracks evict toward as they write.
The budget counts frame payload bytes plus a fixed cost per cached group, which is most of what a group carrying one small frame occupies. It is not process RSS, and it is a convergence target rather than a hard limit; leave headroom when sizing it from real memory.
Sourcepub fn resize(&self, capacity: impl Into<Option<u64>>)
pub fn resize(&self, capacity: impl Into<Option<u64>>)
Change the capacity. None makes the pool unbounded.
Takes effect as tracks write: a shrink leaves the pool over budget, which every subsequent write pays down proportionally. Nothing is reclaimed synchronously.