Pool Infrastructure

The pool infrastructure provides lock-free, zero-allocation object management.

Pool Hierarchy

Pool<T> (interface)

    ├── FreeListPool<T>    - CAS-based lock-free generic pool

    ├── BucketPool<T>      - Size-tiered pool using multiple FreeListPools

    └── MemoryPool          - Specialized pool for FixedMemory

Core Interfaces

Poolable

Any object that can be pooled:

public interface Poolable {
    PoolEntry poolEntry();
    
    default void recycle() {
        poolEntry().recycle();
    }
}

Pool

The main pool interface:

PoolEntry

Tracks pooled objects with slab memory:

FreeListPool

Lock-free pool using CAS-based free-list:

Simple Objects

Objects with Memory

The PoolableFactory receives a SegmentAllocator backed by SlabAllocator:

BucketPool

Size-tiered pool for variable allocations:

Usage

SlabAllocator

Bulk memory allocation with auto-cleanup:

Slab Lifecycle

PoolSettings

Configuration Examples

PoolMetrics

Monitoring Example

Thread Safety

All pool operations are lock-free:

Multiple threads can allocate and recycle concurrently without locks.

Last updated