slots
nimony/lib/std/ioring/core/slots.nim
type Slot = object op: OpContext gen: uint32 inUse: bool nextInFd: int64 prevInFd: int64
type SlotArena = object slots: seq freelist: seq fdHeads: Table
proc init(a: var SlotArena; capacity: int64)proc allocSlot(a: var SlotArena; op: OpContext): int64proc freeSlot(a: var SlotArena; idx: int64)proc hasPendingForFd(a: var SlotArena; fd: int32): boolvar, likeslotsForFd, purely to avoid copying the arena — see there.iterator slotsForFd(a: var SlotArena; fd: int32): int64Yield every in-use slot index for
fd, O(k) in the number of ops on this fd rather than O(MaxOps).aisvareven though nothing here writes to it: the callers all pass a seq element (gSlots[lane].slotsForFd(...)), and for a non-varparameter that materialises a copy of the whole arena —MaxOpsslots, each with a 128-byteSockaddr_storageinside, plus thefdHeadstable — on every call, i.e. megabytes memcpy'd per I/O event.varpasses the arena itself.The body may free the slot it was handed (
complete/closeFdboth do), so the successor is read before yielding — readinga.slots[cur]after the body ran would inspect a slot that is back on the freelist.iterator pendingFds(a: var SlotArena): int32Every fd that has at least one in-flight slot. The table is mutated by
freeSlot, so a caller that completes ops must collect the fds first and dispatch afterwards — nevercompletefrom inside this loop.