Skip to main content

Crate santh_bufpool

Crate santh_bufpool 

Source
Expand description

Typed buffer recycling with fixed size classes and lock-free queues.

The pool keeps four reusable buffer classes: 4 KiB, 64 KiB, 256 KiB, and 1 MiB. Requests are rounded up to the smallest fitting class. If a class is exhausted, the pool falls back to a one-off allocation without blocking.

§Examples

use santh_bufpool::{BufferPool, PoolConfig};

let pool = BufferPool::new(PoolConfig {
    four_kib_count: 2,
    ..PoolConfig::default()
});
let mut buffer = pool.checkout(128).unwrap();
buffer[0] = 42;
assert_eq!(buffer.len(), 128);
assert!(buffer.capacity() >= 128);

Re-exports§

pub use error::Error;
pub use error::Result;

Modules§

error
Error types and constants for bufpool.

Structs§

BufferPool
Fixed-size recyclable buffer pool.
FrozenBuffer
An immutable, shared buffer view.
PoolBuffer
A borrowed buffer from the pool.
PoolConfig
Configuration for a BufferPool.
PoolStats
Pool statistics for observability.
PoolStatsSnapshot
Immutable snapshot of pool statistics.