eve.backend.windows.iocp
Windows Layer 0 readiness backend built on IOCP and WSAPoll.
This backend uses Windows I/O Completion Ports as the core notification mechanism while leveraging WSAPoll for socket readiness detection. The combination provides an IOCP-based architecture with readiness semantics suitable for the Layer 0 abstraction.
Key features:
- WSAPoll-based socket readiness polling (reliable, tested)
- Handle type classification for future non-socket support
- IOCP-based wakeup mechanism via PostQueuedCompletionStatus
- Unified wait combining IOCP wakeups with socket polling
Copyright
Types 9
Handle type classification.
Different handle types require different polling mechanisms on Windows. Currently, only sockets are fully supported via WSAPoll. Other handle types are classified for future IOCP-based overlapped I/O support.
I/O model used for a registered handle.
Determines how the handle is polled for readiness or completion.
Type of I/O operation for overlapped tracking.
Entry in the overlapped I/O pool.
Each entry contains an OVERLAPPED structure, a data buffer, and metadata for tracking the operation. The entry must remain valid until the I/O operation completes. Entry in the overlapped I/O pool.
Each entry contains an OVERLAPPED structure and metadata for tracking the operation. Buffers are provided externally by the caller. The entry must remain valid until the I/O operation completes.
OVERLAPPED overlappedWindows OVERLAPPED structure for async I/O.ulong userDataUser data associated with this operation.HANDLE handleHandle this operation is associated with.void * bufferPtrPointer to external buffer (owned by caller).size_t bufferSizeSize of the external buffer.IoOperation operationType of operation in progress.bool inUseWhether this entry is currently in use.size_t bytesTransferredNumber of bytes transferred (filled on completion).Pool of pre-allocated OVERLAPPED entries for async I/O.
This pool manages the lifecycle of OVERLAPPED structures used for Windows overlapped I/O operations. Entries are acquired before submitting an I/O operation and released when the operation completes.
OverlappedEntry * findByOverlapped(OVERLAPPED * overlappedPtr) @trusted nothrow @nogcFind an entry by its OVERLAPPED pointer.size_t activeCount() @property const pure @safe nothrow @nogcGet the number of active (in-use) entries.bool hasAvailable() @property const pure @safe nothrow @nogcCheck if the pool has available entries.Special completion keys for internal IOCP events.
Native event type returned by this backend.
Mirrors the shape used by the epoll backend to maintain a consistent interface for Layer 1 consumption.
uint eventsReadiness event mask in epoll-compatible format.DataNested data union for compatibility.Registration entry for a handle.
SOCKET socketThe native socket value (for WSAPoll).HANDLE nativeHandleNative handle for non-socket handles.HandleType handleTypeType of handle registered.IoModel ioModelI/O model used for this handle.IoInterest interestRequested readiness interests.ulong userDataUser-provided opaque data.bool activeWhether this slot is actively registered.IOCP-backed poller state for Windows.
This backend maintains an I/O Completion Port handle for the notification mechanism and uses WSAPoll internally for socket readiness detection. The IOCP is also used for efficient cross-thread wakeups.
void * _iocpRegistration[maxRegistrations] _registrationsWSAPOLLFD[maxRegistrations] _pollFdssize_t[maxRegistrations] _pollToRegOverlappedPool _overlappedPoolsize_t _registrationCountsize_t _socketCountsize_t _overlappedCountbool _winsockInitializedbool _pendingWakeupbool isValid() @property const pure @safe nothrow @nogcCheck whether the poller has a valid IOCP handle.Handle handle() @property const pure @trusted nothrow @nogcReturn the native handle wrapper for the IOCP instance.size_t registrationCount() @property const pure @safe nothrow @nogcGet the number of active registrations.size_t overlappedCount() @property const pure @safe nothrow @nogcGet the number of overlapped (non-poll) registrations.OverlappedPool overlappedPool() @property ref return @safe nothrow @nogcGet the overlapped entry pool.int registerHandle(Handle handle, IoInterest interest, ulong userData) @trusted nothrow @nogcRegister a handle with the given interests and opaque user data.int modifyHandle(Handle handle, IoInterest interest, ulong userData) @trusted nothrow @nogcModify the interest mask and user data for an already-registered handle.int unregisterHandle(Handle handle) @trusted nothrow @nogcRemove a handle from the registration table.int associateHandle(HANDLE handle, ulong completionKey) @trusted nothrow @nogcAssociate a handle with the IOCP for overlapped I/O.int wait(scope NativeEvent[] nativeEvents, int timeoutMs) @trusted nothrow @nogcWait for native events.OsEvent translate(ref const(NativeEvent) nativeEvent) pure @safe nothrow @nogcTranslate a native event into the shared Layer 0 event shape.IoReady translateReady(uint nativeMask) pure @safe nothrow @nogcTranslate a native readiness mask into shared readiness flags.Functions 3
short toNativeMask(IoInterest interest) pure @safe nothrow @nogcConvert IoInterest to native WSAPoll mask.uint toEpollMask(short pollMask) pure @safe nothrow @nogcConvert WSAPoll revents mask to epoll-compatible mask.IoReady fromNativeMask(uint mask) pure @safe nothrow @nogcConvert epoll-compatible mask to shared IoReady flags.Variables 2
maxRegistrations = 1024Maximum number of registrations supported.
This limit applies to the total number of handles (sockets, pipes, files) that can be registered with a single event loop. If your application needs more than 1024 concurrent I/O watchers, you may need to use multiple event loops or restructure your application.
Note
Future versions may support dynamic sizing via EventLoopConfig.watcherCapacity.
MAX_OVERLAPPED_ENTRIES = 64Maximum number of overlapped entries in the pool.