eve.aio.windows.pipe
Async pipe primitives for Windows.
This module provides the Windows implementation of anonymous pipe primitives. On Windows, anonymous pipes created with CreatePipe do not support overlapped I/O directly, so this implementation uses named pipes with unique names for event loop integration.
Backpressure is modelled via an all-or-nothing write policy: write() either accepts all bytes (OK) or rejects with PRESSURE. A per-pipe send queue buffers data until the kernel can drain it. When the queue drains below the low water mark, onWritable fires.
See Also
Types 8
Pipe buffer configuration.
size_t bufferSizeSize of the internal read/write buffer.size_t highWaterMarkMaximum send queue size before backpressure is applied.size_t lowWaterMarkSend queue size at which backpressure is lifted and `onWritable` fires.Async pipe end wrapper.
Represents one end of a pipe - either the read or write end. Wraps a non-blocking pipe handle and integrates with the Layer 1 event loop for async read/write operations.
private PipeEndState _statevoid onData(DataCallback callback) @safe Register a callback for data available (read end). Fires when data arrives. The `data` parameter is borrowed — valid only for the duration of the callback. Copy it if needed beyond. Thread a...void onWritable(WritableCallback callback) @safe Register a callback for writability (write end). Fires when the send queue drains below the low water mark after backpressure. Not called on initial open. Thread affinity: event loop thread on...void onClose(CloseCallback callback) @safe Register a callback for pipe close. Fires when the peer closes the pipe or a fatal error occurs. Does not fire after `dispose()`. Thread affinity: event loop thread only. Non-reentrant. Does ...Internal state for a pipe end using IOCP overlapped I/O.
This implementation uses Windows overlapped I/O with completion ports instead of polling. Each pipe end has its own OVERLAPPED structure and buffers that remain valid until the I/O completes.
The pipe integrates with the event loop via a wakeup watcher that is notified when IOCP completions arrive.
DataCallback onDataWritableCallback onWritableCloseCallback onCloseErrorCallback onErrorprivate EventLoop * _loopReference to the event loop this pipe is registered with.private Handle _handleThe underlying Windows pipe handle.private PipeConfig _configPipe configuration (buffer sizes, etc.).private bool _isReadEndWhether this is the read end (`true`) or write end (`false`).private bool _readingPausedWhether reading is paused (read end only).private bool _closeDeliveredWhether the close callback has been delivered.private PipeState _pipeStateCurrent lifecycle state of the pipe.private OVERLAPPED _readOverlappedOverlapped structure for pending read operations.private OVERLAPPED _writeOverlappedOverlapped structure for pending write operations.private ubyte[PIPE_READ_BUFFER_SIZE] _readBufferRead buffer — must remain valid during overlapped read.private ubyte[PIPE_READ_BUFFER_SIZE] _writeBufferWrite buffer — must remain valid during overlapped write.private bool _readInProgressWhether a read operation is currently in progress.private bool _writeInProgressWhether a write operation is currently in progress.private bool _awaitingWritableWhether we're waiting for backpressure to clear before notifying writable.private size_t _pendingWriteLenNumber of bytes in the current pending write.private ubyte[] _sendQueueQueue of data waiting to be written.void pipeCompletionCallback(void * context, OVERLAPPED * overlappedPtr,
size_t bytesTransferred, DWORD error) static @trusted nothrowStatic IOCP completion callback.int associateWithIocp() @trusted nothrowAssociate the pipe handle with the event loop's IOCP.void processReadCompletionData(DWORD bytesRead, DWORD error) @trusted nothrowProcess a completed read operation using IOCP completion data.void processWriteCompletionData(DWORD bytesWritten, DWORD error) @trusted nothrowProcess a completed write operation using IOCP completion data.void fail(int errorNumber) @trusted nothrow Transition the pipe to error state. Invokes the error callback and closes the pipe. Params: errorNumber = The error code to report.void closeInternal(PipeCloseReason reason, int errorNumber, bool invokeCallback) @trusted nothrowInternal close implementation.this(PipeConfig config)Functions 8
Variables 1
PIPE_READ_BUFFER_SIZE = 4096Size of the internal read/write buffer for overlapped I/O.