import { Metrics } from "../metrics/metrics.js";
export declare enum AllocSource {
    PERSISTENT_CHECKPOINTS_CACHE_VALIDATORS = "persistent_checkpoints_cache_validators",
    PERSISTENT_CHECKPOINTS_CACHE_STATE = "persistent_checkpoints_cache_state",
    ARCHIVE_STATE = "archive_state"
}
/**
 * A simple implementation to manage a single buffer.
 * This is initially used for state serialization at every epoch and for state reload.
 * We can enhance and use this for other purposes in the future.
 */
export declare class BufferPool {
    private buffer;
    private inUse;
    private currentKey;
    private readonly metrics;
    constructor(size: number, metrics?: Metrics | null);
    get length(): number;
    /**
     * Returns a buffer of the given size with all 0.
     * If the buffer is already in use, return null.
     * Grow the buffer if the requested size is larger than the current buffer.
     */
    alloc(size: number, source: AllocSource): BufferWithKey | null;
    /**
     * Same to alloc() but the buffer is not zeroed.
     */
    allocUnsafe(size: number, source: AllocSource): BufferWithKey | null;
    private doAlloc;
    /**
     * Marks the buffer as free.
     */
    free(key: number): void;
}
export declare class BufferWithKey implements Disposable {
    readonly buffer: Uint8Array;
    private readonly key;
    private readonly pool;
    constructor(buffer: Uint8Array, key: number, pool: BufferPool);
    [Symbol.dispose](): void;
}
//# sourceMappingURL=bufferPool.d.ts.map