eve.core.posix.loop

Shared POSIX utilities for Layer 1 event loop implementations.

This module provides common POSIX types, signal handling utilities, and helper functions used by both Linux and BSD/macOS event loop backends. Platform-specific implementations (loop_linux.d, loop_kqueue.d) import this module for shared functionality.

Types 1

Configuration for EventLoop.create.

Fields
size_t watcherCapacityNumber of watcher slots preallocated at loop creation.
size_t eventCapacityNumber of native events buffered per backend poll operation.
size_t dnsCapacityNumber of asynchronous DNS resolution slots preallocated.
EventLoopLimits limitsResource limits configuration.
bool delegate(LimitKind kind, size_t current, size_t limit) @safe nothrow onLimitApproachingCalled when a limit is about to be hit (if `LimitAction.callback` is set).
void delegate(LimitKind kind) @safe nothrow onLimitExceededCalled when a limit is exceeded and the action is `reject`.

Functions 15

fnsize_t normalizedWatcherCapacity(size_t requested) pure @safe nothrow @nogcNormalize a requested watcher capacity to a minimum sane value.
fnsize_t normalizedDnsCapacity(size_t requested) pure @safe nothrow @nogcNormalize a requested DNS capacity to a minimum sane value.
fnsize_t normalizedEventCapacity(size_t requested) pure @safe nothrow @nogcNormalize a requested event capacity to a minimum sane value.
fnuint nextGeneration(uint generation) pure @safe nothrow @nogcAdvance a generation counter, skipping zero.
fnulong packToken(Token token) pure @safe nothrow @nogcPack a watcher token into a 64-bit user data value.
fnToken unpackToken(ulong userData) pure @safe nothrow @nogcUnpack a 64-bit user data value into a watcher token.
fnint signalNumber(Signal signal) pure @safe nothrow @nogcMap a normalized signal to its POSIX signal number.
fnsigset_t signalMask(Signal signal) @trusted nothrowCreate a signal mask containing a single signal.
fnint blockSignalMask(sigset_t mask, sigset_t * savedMask = null) @trusted nothrowBlock a signal mask and optionally save the previous mask.
fnint restoreSignalMask(ref const(sigset_t) savedMask) @trusted nothrowRestore a previously saved signal mask.
fnint[2] createPipe() @trusted nothrowCreate a pipe pair for internal wakeup or communication.
fnvoid closePipe(ref int[2] fds) @trusted nothrowClose a pipe pair, handling already-closed descriptors.
fnint closeIfValid(int fd) @trusted nothrowClose a single file descriptor if valid.
fnint closeHandle(Handle handle) @trusted nothrowClose a handle if valid (POSIX version).
fnint setNonBlocking(Handle handle) @trusted nothrow @nogcSet a file descriptor to non-blocking mode.

Templates 4

tmplIoWatcherCallbackOf(EventLoop)

Callback signature template for I/O watchers.

Platform implementations should define:

alias IoWatcherCallback = void delegate(ref EventLoop loop, Token token, IoReady ready) @safe nothrow;

tmplWatcherCallbackOf(EventLoop)

Callback signature template for timer, phase, and wakeup watchers.

Platform implementations should define:

alias WatcherCallback = void delegate(ref EventLoop loop, Token token) @safe nothrow;

tmplSignalWatcherCallbackOf(EventLoop)

Callback signature template for signal watchers.

Platform implementations should define:

alias SignalWatcherCallback = void delegate(ref EventLoop loop, Token token, SignalInfo info) @safe nothrow;

tmplDnsWatcherCallbackOf(EventLoop)

Callback signature template for DNS resolution.

Platform implementations should define:

alias DnsWatcherCallback = void delegate(ref EventLoop loop, Token token, scope const(IpAddress)[] addrs, DnsError error) @safe nothrow;