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.

var _errno
struct EventLoop

Types 1

structEventLoop

Single-threaded readiness event loop for Windows.

Fields
private SelectedBackend _poller
private WatcherSlot[] _slots
private NativeEvent[] _events
private ResourceAccounting _resources
private DnsManager _dns
private PhaseWatchers _phases
private TimerWheel _timerWheel
private TimerState _timer
private SignalState _signals
private size_t _watcherCount
private WindowsSocketBackend _windowsSocketBackend
private bool _running
private bool _stopRequested
private uint _freeHead
private PostState _post
private ulong _registrationSeq
private void delegate(Token, Exception) @safe nothrow _onCallbackError
Methods
EventLoop create(EventLoopConfig config = EventLoopConfig.init) static @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.
int registerCompletion(void * context, CompletionCallback callback) @trusted nothrowRegister a completion handler for IOCP completions.
void unregisterCompletion(void * context) @trusted nothrowUnregister a completion handler.
BackendId backendId() @property const @safe nothrow @nogcReturn the identifier of the active Layer 0 backend.
BackendCapabilities backendCapabilities() @property const @safe nothrow @nogcReturn the capability flags for the active Layer 0 backend.
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.
bool usingIocp() @property const pure @safe nothrow @nogcReport whether the loop is using IOCP overlapped I/O mode.
ResourceUsage usage() const @safe nothrow @nogcGet the current resource usage of the event loop.
ResourceUsage diagnostics() const @safe nothrow @nogcGet a snapshot of current diagnostics.
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.
bool checkLimit(LimitKind kind, size_t current, size_t limit) @safe nothrowInternal: Check if a resource limit is hit.
int dispose() @trusted nothrowDispose the Layer 0 poller and invalidate all watcher tokens.
Token registerIo(Handle handle, IoInterest interest, IoWatcherCallback callback, WatcherFlags extraFlags = WatcherFlags.none) @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.
void defer(void delegate() @safe nothrow callback) @safe nothrowDefer a callback to the next loop iteration.
void post(void delegate() @safe nothrow callback) @trusted nothrowPost a callback from any thread for execution on the loop thread.
void reportCallbackError(Token token, Exception error) @trusted nothrow
ptrdiff_t countPhaseWatchers(WatcherKind kind) const pure @safe nothrow @nogcCount enabled phase watchers of the given kind.
private void ensurePostWakeup() @trusted nothrow
private void drainDeferQueue() @trusted nothrow
private void rebuildFreeList() @safe nothrow @nogc
private void resetSlot(uint index, ref WatcherSlot slot) @trusted nothrow @nogc
private Token allocateToken() @safe nothrow @nogc
private WatcherSlot * slotFor(Token token) @safe nothrow @nogc
private void cleanupSlotResources(uint index, ref WatcherSlot slot) @trusted nothrow
private int detachSlotFromBackend(uint index, ref WatcherSlot slot) @trusted nothrow
private int removeSlotNow(uint index, ref WatcherSlot slot) @trusted nothrow
private void releaseToken(uint index) @trusted nothrow @nogc
private Token registerPhaseWatcher(WatcherKind kind, WatcherCallback callback) @trusted nothrow
private int computePollTimeout(int requestedTimeoutMs) const @safe nothrow @nogc
private long currentTimeMs() @trusted nothrow @nogc
private ptrdiff_t fireExpiredTimers() @trusted nothrow
private bool dispatchTimer(Token token) @trusted nothrow
private bool dispatchWatcherLocal(Token token) @trusted nothrow
private bool dispatchIoLocal(Token token, IoReady ready) @trusted nothrow
private bool dispatchOsEventLocal(OsEvent osEvent) @trusted nothrow
private void checkDnsEvents() @trusted nothrow
private void checkWakeupEvents() @trusted nothrow
private void checkSignalEvents() @trusted nothrow
private void installConsoleHandler() @trusted nothrow
private bool consoleHandlerInstalled() @property const @safe nothrow @nogc
Nested Templates
WatcherSlot

Functions 1

private fnint errno() ref @trusted nothrow @nogc

Variables 1

private varint _errno

Thread-local errno for Windows compatibility.