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§
Modules§
- error
- Error types and constants for bufpool.
Structs§
- Buffer
Pool - Fixed-size recyclable buffer pool.
- Frozen
Buffer - An immutable, shared buffer view.
- Pool
Buffer - A borrowed buffer from the pool.
- Pool
Config - Configuration for a
BufferPool. - Pool
Stats - Pool statistics for observability.
- Pool
Stats Snapshot - Immutable snapshot of pool statistics.