eve.core.linux.slots

Watcher slot pool for the Linux event loop.

This module provides free-list-based slot allocation, token management, and slot lookup for the Linux EventLoop. It operates on a generic Slot type that must expose certain metadata fields (kind, flags, generation, handle, interest, nextFree, registrationSeq).

By parameterizing on the concrete slot type, this module avoids a circular dependency on the full EventLoop definition.

struct SlotPool

Types 1

structSlotPool(Slot)

Free-list-based watcher slot pool.

Manages a contiguous array of watcher slots with O(1) allocate and release operations. Each slot carries a generation counter that is incorporated into tokens to detect stale references after release.

Parameters

SlotStruct type with at minimum fields: kind, flags, generation, handle, interest, cancelToken, nextFree, registrationSeq.
Fields
Slot[] slots
uint freeHead
size_t watcherCount
ulong registrationSeq
HeapEntry[] _heap
size_t _heapSize
Methods
void initialize(size_t capacity) @trusted nothrowInitialize the pool with a fixed slot capacity.
void dispose() @safe nothrow @nogcReset all pool state.
void rebuildFreeList() @safe nothrow @nogcRebuild the free list from all slots.
Token allocate() @safe nothrow @nogcAllocate a token from the free list.
Slot * slotFor(Token token) @safe nothrow @nogcLook up a slot by token.
void release(uint index) @trusted nothrow @nogcRelease a slot back to the free list.
void heapPush(ulong seq, uint slotIndex) @trusted nothrow @nogcInsert a slot into the registration-order min-heap.
bool heapPop(out uint outIndex) @trusted nothrow @nogcPop the oldest entry from the min-heap, skipping stale entries.
private void resetSlot(uint index, ref Slot slot) @trusted nothrow @nogc
Nested Templates
HeapEntryMin-heap entry tracking registration order for O(1) oldest lookup.