eve.backend.linux.uring

Linux runtime-selected Layer 0 backend.

On kernels that allow io_uring, this module exposes a real io_uring-backed readiness poller. When setup is rejected or unavailable it falls back to the reliable epoll backend so higher layers still have a usable Linux path.

Types 2

private enumOperationKind : ubyte
POLL = 1
REMOVE = 2
structOsPoller

Linux Layer 0 poller that prefers io_uring and falls back to epoll when the runtime rejects io_uring setup.

Fields
private bool _usingFallback
private bool _ioUringAvailable
private bool _sqpollActive
private uint _sqThreadIdle
private int _probeError
private int _fd
private void * _sqRing
private void * _cqRing
private void * _sqesRegion
private size_t _sqRingLength
private size_t _cqRingLength
private size_t _sqesLength
private bool _singleMmap
private shared(uint) * _sqHead
private shared(uint) * _sqTail
private shared(uint) * _sqRingMask
private shared(uint) * _sqRingEntries
private shared(uint) * _sqArray
private io_uring_sqe * _sqes
private shared(uint) * _cqHead
private shared(uint) * _cqTail
private shared(uint) * _cqRingMask
private shared(uint) * _cqRingEntries
private io_uring_cqe * _cqes
private Registration * _registrations
private size_t _registrationCapacity
private NativeEvent * _pendingEvents
private size_t _pendingHead
private size_t _pendingCount
private ulong _submitSequence
private uint * _fdToSlot
private size_t _fdToSlotMask
private KernelTimespec _timeoutSpec
private uint _emptySlot
Methods
private void htInsert(int fd, uint slotIndex) @trusted nothrow @nogc
private void htRemove(int fd) @trusted nothrow @nogc
private uint load(shared(uint) * value) static @trusted nothrow @nogc
private void store(shared(uint) * value, uint payload) static @trusted nothrow @nogc
private ulong makeOperationId(uint slotIndex, OperationKind kind, ulong sequence) static pure @safe nothrow @nogc
private OperationKind operationKind(ulong userData) static pure @safe nothrow @nogc
private uint operationSlot(ulong userData) static pure @safe nothrow @nogc
private size_t maxSize(size_t left, size_t right) static pure @safe nothrow @nogc
private size_t pendingIndex(size_t offset) const pure @safe nothrow @nogc
private Registration slot(uint index) ref @trusted nothrow @nogc
private const(Registration) slot(uint index) ref const @trusted nothrow @nogc
private int initializeIoUring(bool sqpoll = false, uint sqThreadIdle = 0) @trusted nothrow @nogc
private void cleanupIoUring() @trusted nothrow @nogc
private int submit(uint count) @trusted nothrow @nogc
private io_uring_sqe * acquireSqe() @trusted nothrow @nogc
private int findRegistration(Handle handle) const @trusted nothrow @nogc
private int findFreeRegistration() const @safe nothrow @nogc
private ulong nextOperationId(uint slotIndex, OperationKind kind) @safe nothrow @nogc
private int submitPollAdd(uint slotIndex) @trusted nothrow @nogc
private int submitPollAddWithTimeout(uint slotIndex, int timeoutMs, ulong timeoutUserData) @trusted nothrow @nogcSubmit a poll_add SQE chained with a linked timeout.
private int submitPollRemove(ulong targetUserData, ulong userData) @trusted nothrow @nogc
private bool queueEvent(NativeEvent event) @trusted nothrow @nogc
private int flushPending(scope NativeEvent[] nativeEvents) @trusted nothrow @nogc
private int waitForRing(int timeoutMs) @trusted nothrow @nogc
private size_t activeRegistrationCount() const @safe nothrow @nogc
private bool processCompletion(ref const(io_uring_cqe) cqe, scope NativeEvent[] output, ref int written, ulong awaitedUserData, ref int awaitedResult) @trusted nothrow @nogc
private bool drainCompletions(scope NativeEvent[] output, ref int written, ulong awaitedUserData, ref int awaitedResult) @trusted nothrow @nogc
private int waitForOperation(ulong awaitedUserData) @trusted nothrow @nogc
OsPoller create() static @trusted nothrow @nogcCreate a new Linux poller.
OsPoller create(bool sqpoll, uint sqThreadIdle = 20) static @trusted nothrow @nogcCreate a new Linux poller with optional SQPOLL mode.
bool isValid() @property const pure @safe nothrow @nogcCheck whether the active backend was created successfully.
bool ioUringAvailable() @property const pure @safe nothrow @nogcReport whether `io_uring` is active for this poller instance.
bool sqpollActive() @property const pure @safe nothrow @nogcReport whether SQPOLL mode is active.
uint sqThreadIdle() @property const pure @safe nothrow @nogcReport the configured SQPOLL thread idle timeout.
bool usingFallback() @property const pure @safe nothrow @nogcReport whether this poller instance is using the `epoll` fallback path.
int probeError() @property const pure @safe nothrow @nogcReturn the last `io_uring` setup error.
BackendId backendId() @property const pure @safe nothrow @nogcReturn the identifier of the active backend.
BackendCapabilities capabilities() @property const pure @safe nothrow @nogcReturn the capability flags for the active backend.
Handle handle() @property const pure @safe nothrow @nogcReturn the native handle wrapper for the active backend.
int dispose() @trusted nothrow @nogcDispose the active backend state.
int registerHandle(Handle handle, IoInterest interest, ulong userData, WatcherFlags flags = WatcherFlags.none) @trusted nothrow @nogc Register a handle with the active backend. Params: handle = Handle to register. interest = Requested readiness mask. userData = Opaque value returned in translated events. ...
int modifyHandle(Handle handle, IoInterest interest, ulong userData, WatcherFlags flags = WatcherFlags.none) @trusted nothrow @nogc Modify the interest mask and user data for a registered handle. Params: handle = Registered handle to update. interest = New readiness mask. userData = Replacement opaque value....
int unregisterHandle(Handle handle) @trusted nothrow @nogcRemove a handle from the active backend.
int wait(scope NativeEvent[] nativeEvents, int timeoutMs) @trusted nothrow @nogc Wait for native events from the active backend. Params: nativeEvents = Caller-provided output buffer for native events. timeoutMs = Wait timeout in milliseconds. `-1` means infinite...
OsEvent translate(ref const(NativeEvent) nativeEvent) static pure @safe nothrow @nogcTranslate a native backend event into the shared Layer 0 event shape.
IoReady translateReady(uint nativeMask) static pure @safe nothrow @nogcTranslate a native readiness mask into shared readiness flags.
Nested Templates
Registration

Functions 3

private fnushort toNativeMask(IoInterest interest) pure @safe nothrow @nogc
private fnuint nativeMaskFromResult(int result) pure @safe nothrow @nogc
private fnint probeIoUringSupport() @trusted nothrow @nogc

Variables 1

private enumvarrequestedRingEntries = 1024u