pub struct SymbolPool { /* private fields */ }Expand description
A pool of fixed-size symbol buffers.
Implementations§
Source§impl SymbolPool
impl SymbolPool
Sourcepub fn new(config: PoolConfig) -> Self
pub fn new(config: PoolConfig) -> Self
Creates a new symbol pool using the provided configuration.
br-asupersync-jpzl5a — Mints pool_id from a process-global
counter. This is fine for accounting / back-pressure decisions
where the only contract is “distinct pools have distinct ids”,
but it leaks ambient identity that breaks deterministic replay
across separate LabRuntime instances. Determinism-sensitive
callers should use Self::new_with_pool_id and supply an ID
minted from the runtime-scoped allocator they already hold.
Sourcepub fn new_with_pool_id(config: PoolConfig, pool_id: u64) -> Self
pub fn new_with_pool_id(config: PoolConfig, pool_id: u64) -> Self
br-asupersync-jpzl5a — Creates a new symbol pool with an
explicit pool_id. Use this from runtime-scoped factories that
want pool identity tied to a deterministic allocator (e.g. a
per-runtime counter or a Cx-derived hash) rather than the
process-global atomic in Self::new.
Sourcepub fn config(&self) -> &PoolConfig
pub fn config(&self) -> &PoolConfig
Returns the current pool configuration.
Sourcepub fn free_count(&self) -> usize
pub fn free_count(&self) -> usize
Returns the number of buffers currently available in the free list.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Resets pool statistics while keeping current usage.
Sourcepub fn allocate(&mut self) -> Result<SymbolBuffer, PoolExhausted>
pub fn allocate(&mut self) -> Result<SymbolBuffer, PoolExhausted>
Allocates a symbol buffer or returns PoolExhausted.
Sourcepub fn try_allocate(&mut self) -> Option<SymbolBuffer>
pub fn try_allocate(&mut self) -> Option<SymbolBuffer>
Attempts to allocate a symbol buffer without blocking.
Sourcepub fn deallocate(&mut self, buffer: SymbolBuffer)
pub fn deallocate(&mut self, buffer: SymbolBuffer)
Returns a buffer to the pool.
§Panics
Panics if the buffer’s size does not match the pool’s configured symbol size, if it was never checked out from a pool, or if it belongs to a different pool.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the free list to the minimum size based on the initial pool size.