eve.core.windows.loop

Windows Layer 1 event loop built on the selected Layer 0 backend.

This module provides the Windows-specific implementation of EventLoop using performance counters for timers, SetConsoleCtrlHandler for signals, and Windows Event objects for cross-thread wakeups.

Types 3

Backend selection for Windows socket I/O.

Controls how sockets are polled for readiness on Windows.

WSAPOLLUse WSAPoll for socket readiness polling. This is the legacy fallback option.
IOCP_OVERLAPPEDUse IOCP overlapped I/O for completion notification. Better performance, unified model with pipes/files. This is the default backend.

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`.
WindowsSocketBackend windowsSocketBackendWindows socket backend selection.
structEventLoop

Single-threaded readiness event loop for Windows.

Fields
SelectedBackend _poller
WatcherSlot[] _slots
NativeEvent[] _events
DnsData[] _dnsSlots
size_t _watcherCount
size_t _totalSendQueueBytes
size_t _activeConnections
size_t _openFds
bool _running
bool _stopRequested
uint _freeHead
uint _dnsFreeHead
Token[] _phaseBuffer
long _perfFreq
long _startTime
bool _consoleHandlerInstalled
Methods
EventLoop create(EventLoopConfig config = EventLoopConfig.init) @trustedCreate a new event loop with fixed-capacity watcher and event buffers.
bool isValid() @property const @safe nothrow @nogcCheck whether the loop was created successfully.
Handle backendHandle() @property const @safe nothrow @nogcReturn the native handle for the active Layer 0 poller.
size_t watcherCount() @property const pure @safe nothrow @nogcReport how many watchers are currently registered.
bool isRunning() @property const pure @safe nothrow @nogcReport whether `run` or `runToCompletion` is currently executing.
WindowsSocketBackend windowsSocketBackend() @property const pure @safe nothrow @nogcGet the configured Windows socket backend.
ResourceUsage usage() const @safe nothrow @nogcGet the current resource usage of the event loop.
const(EventLoopLimits) limits() @property const @safe nothrow @nogcGet the resource limits configured for the event loop.
void updateSendQueueUsage(long delta) @safe nothrow @nogcUpdate the total send queue bytes tracked by the loop.
void updateConnectionCount(long delta) @safe nothrow @nogcUpdate the active connection count tracked by the loop.
int dispose() @trusted nothrowDispose the Layer 0 poller and invalidate all watcher tokens.
Token registerIo(Handle handle, IoInterest interest, IoWatcherCallback callback) @trusted nothrowRegister an I/O watcher with the selected backend.
Token registerTimer(long delayMs, long intervalMs, WatcherCallback callback) @trusted nothrowRegister a one-shot timer watcher.
Token registerSignal(Signal signal, SignalWatcherCallback callback) @trusted nothrowRegister a signal watcher.
Token registerWakeup(WatcherCallback callback) @trusted nothrowRegister an async wakeup watcher.
int notify(Token token) @trusted nothrowTrigger an async wakeup watcher.
void updateDnsResults(Token token, scope const(IpAddress)[] results, DnsError error) @safe nothrowInternal: Update results for a DNS watcher.
const(char) * getDnsHostname(Token token) @safe nothrowInternal: Get the hostname associated with a DNS watcher.
Token registerDns(scope const(char)[] host, DnsWatcherCallback callback, CancelToken cancel = CancelToken .invalid) @trusted nothrowRegister an async DNS resolution watcher.
CancelToken getCancelToken(Token token) @safe nothrow @nogcGet the cancellation token associated with a watcher.
Token registerPrepare(WatcherCallback callback) @trusted nothrowRegister a prepare watcher.
Token registerCheck(WatcherCallback callback) @trusted nothrowRegister a check watcher.
Token registerIdle(WatcherCallback callback) @trusted nothrowRegister an idle watcher.
int updateIo(Token token, IoInterest interest) @trusted nothrowUpdate the interest mask for an existing I/O watcher.
int unregister(Token token) @trusted nothrowUnregister an active watcher.
ptrdiff_t runOnce(int timeoutMs) @trusted nothrowRun one iteration of the event loop.
ptrdiff_t run() @trusted nothrowRun the event loop until `stop` is called.
ptrdiff_t runToCompletion() @trusted nothrowRun the event loop until no active watchers remain.
void stop() @trusted nothrowRequest the loop to stop after the current iteration.
bool checkLimit(LimitKind kind, size_t current, size_t limit) @safe nothrowInternal: Check if a resource limit is hit.
size_t normalizedWatcherCapacity(size_t requested) pure @safe nothrow @nogc
size_t normalizedEventCapacity(size_t requested) pure @safe nothrow @nogc
size_t normalizedDnsCapacity(size_t requested) pure @safe nothrow @nogc
uint nextGeneration(uint generation) pure @safe nothrow @nogc
ulong packToken(Token token) pure @safe nothrow @nogc
Token unpackToken(ulong userData) pure @safe nothrow @nogc
void rebuildFreeList() @safe nothrow @nogc
void rebuildDnsFreeList() @safe nothrow @nogc
void resetSlot(uint index, ref WatcherSlot slot) @trusted nothrow @nogc
Token allocateToken() @safe nothrow @nogc
WatcherSlot * slotFor(Token token) @safe nothrow @nogc
void cleanupSlotResources(uint index, ref WatcherSlot slot) @trusted nothrow
int detachSlotFromBackend(uint index, ref WatcherSlot slot) @trusted nothrow
int removeSlotNow(uint index, ref WatcherSlot slot) @trusted nothrow
void releaseToken(uint index) @trusted nothrow @nogc
uint allocateDnsSlot() @safe nothrow @nogc
void releaseDnsSlot(uint index) @safe nothrow @nogc
Token registerPhaseWatcher(WatcherKind kind, WatcherCallback callback) @trusted nothrow
int computePollTimeout(int requestedTimeoutMs) @trusted nothrow @nogc
long findNearestTimerExpiration() @trusted nothrow @nogc
long currentTimeMs() @trusted nothrow @nogc
ptrdiff_t fireExpiredTimers() @trusted nothrow
bool hasPhaseOnlyWatchers() const @safe nothrow @nogc
ptrdiff_t dispatchPhase(WatcherKind kind) @trusted nothrow
bool dispatchWatcher(Token token) @trusted nothrow
bool dispatchIo(Token token, IoReady ready) @trusted nothrow
bool dispatchOsEvent(OsEvent osEvent) @trusted nothrow
void checkDnsEvents() @trusted nothrow
void checkWakeupEvents() @trusted nothrow
void checkSignalEvents() @trusted nothrow
bool hasSignalWatcher(Signal signal) const @safe nothrow @nogc
void installConsoleHandler() @trusted nothrow
Nested Templates
WatcherSlot
DnsData

Functions 2

private fnint errno() ref @trusted nothrow @nogc
private fnint consoleCtrlHandler(uint ctrlType) nothrow

Variables 3

private varint _errno

Thread-local errno for Windows compatibility.

private varbool _pendingInterrupt
private varbool _pendingTerminate