Expand description
Fixed-size object pool allocator.
A pool allocator pre-allocates a contiguous slab of equal-sized blocks and maintains a lock-free free-list over them. Allocation pops one block from the free-list; deallocation pushes it back.
§Characteristics
| Property | Value |
|---|---|
| Allocation / deallocation cost | O(1), typically a single CAS |
| Fragmentation | Zero (fixed-size blocks) |
| Thread safety | Lock-free (AtomicPtr CAS loop) |
| Max allocation size | block_layout.size() |
| Individual deallocation | ✅ Supported |
§Example
ⓘ
let pool = PoolAllocator::typed::<[u8; 64]>(&sys, 128).unwrap();
let ptr = unsafe { pool.alloc(Layout::new::<[u8; 64]>()) }.unwrap();
// ... use memory ...
unsafe { pool.dealloc(ptr, Layout::new::<[u8; 64]>()) };Structs§
- Pool
Allocator - A lock-free, fixed-size block allocator backed by a single pre-allocated slab.