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.

Types 8

Pipe buffer configuration.

Fields
size_t bufferSizeSize of the internal read/write buffer.
Methods
bool isValid() @property const pure @safe nothrow @nogcValidate the config.
private aliasDataCallback = void delegate(ref Pipe pipe, scope const(ubyte)[] data) @safe
private aliasWritableCallback = void delegate(ref Pipe pipe) @safe
private aliasCloseCallback = void delegate(ref Pipe pipe, PipeCloseReason reason) @safe
private aliasErrorCallback = void delegate(ref Pipe pipe, int errorNumber) @safe
structPipe

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.

Fields
Methods
Pipe create(PipeConfig config = PipeConfig.init) @trustedCreate a detached pipe wrapper.
void onData(DataCallback callback) @safeRegister a callback for data available (read end).
void onWritable(WritableCallback callback) @safeRegister a callback for writability (write end).
void onClose(CloseCallback callback) @safeRegister a callback for pipe close.
void onError(ErrorCallback callback) @safeRegister a callback for pipe errors.
bool isOpen() @property const @safe nothrow @nogcCheck whether the pipe is open.
PipeState state() @property const @safe nothrow @nogcGet the current pipe state.
int adoptRead(ref EventLoop loop, Handle readEnd) @trustedAdopt a pipe handle for reading.
int adoptWrite(ref EventLoop loop, Handle writeEnd) @trustedAdopt a pipe handle for writing.
SendResult write(scope const(ubyte)[] data) @trustedWrite bytes to the pipe (write end only).
void pauseReading() @trusted nothrowPause read delivery.
void resumeReading() @trusted nothrowResume read delivery.
void close() @trusted nothrowClose the pipe end.
void dispose() @trusted nothrowDispose the pipe and its watcher registration.
structPipePair

Represents a pair of pipe ends.

Fields
Handle readEndHandle for reading from the pipe.
Handle writeEndHandle for writing to the pipe.
Methods
bool isValid() @property const @safe nothrow @nogcCheck whether both pipe ends are valid.
private classPipeEndState

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.

Fields
WritableCallback onWritable
EventLoop * _loopReference to the event loop this pipe is registered with.
Handle _handleThe underlying Windows pipe handle.
Token _prepareTokenPrepare token for polling IOCP completion status.
PipeConfig _configPipe configuration (buffer sizes, etc.).
bool _isReadEndWhether this is the read end (`true`) or write end (`false`).
bool _readingPausedWhether reading is paused (read end only).
bool _closeDeliveredWhether the close callback has been delivered.
PipeState _pipeStateCurrent lifecycle state of the pipe.
OVERLAPPED _readOverlappedOverlapped structure for pending read operations.
OVERLAPPED _writeOverlappedOverlapped structure for pending write operations.
ubyte[PIPE_READ_BUFFER_SIZE] _readBufferRead buffer — must remain valid during overlapped read.
ubyte[PIPE_READ_BUFFER_SIZE] _writeBufferWrite buffer — must remain valid during overlapped write.
bool _readInProgressWhether a read operation is currently in progress.
bool _writeInProgressWhether a write operation is currently in progress.
bool _awaitingWritableWhether we're waiting for backpressure to clear before notifying writable.
size_t _pendingWriteLenNumber of bytes in the current pending write.
ubyte[] _sendQueueQueue of data waiting to be written.
Methods
bool isOpen() @property const @safe nothrow @nogc
int adoptRead(ref EventLoop loop, Handle readEnd) @trusted nothrow
int adoptWrite(ref EventLoop loop, Handle writeEnd) @trusted nothrow
SendResult write(scope const(ubyte)[] data) @trusted nothrow
void pauseReading() @trusted nothrow
void resumeReading() @trusted nothrow
void closeExplicitly() @trusted nothrowExplicitly close this pipe end.
void handlePrepare(ref EventLoop loop, Token token) @trusted nothrowHandle prepare phase callback from the event loop.
Pipe owner() @safe nothrow
int associateWithIocp() @trusted nothrowAssociate the pipe handle with the event loop's IOCP.
void submitRead() @trusted nothrowSubmit an overlapped read operation.
void processReadCompletion() @trusted nothrowProcess a completed read operation.
void submitWrite() @trusted nothrowSubmit an overlapped write operation.
void processWriteCompletion() @trusted nothrowProcess a completed write operation.
void fail(int errorNumber) @trusted nothrowTransition the pipe to error state.
void closeInternal(PipeCloseReason reason, int errorNumber, bool invokeCallback) @trusted nothrowInternal close implementation.
void closeWithoutCallback() @trusted nothrow
void invokeData(scope const(ubyte)[] data) @trusted nothrow
void invokeWritable() @trusted nothrow
void invokeError(int errorNumber) @trusted nothrow
void invokeClose(PipeCloseReason reason) @trusted nothrow
Constructors

Functions 8

fnPipePair createPipe() @trusted nothrowCreate an anonymous pipe pair.
fnvoid closePipe(ref PipePair pair) @trusted nothrowClose both ends of a pipe pair.
private fnPipeConfig validated(PipeConfig config) pure @safe nothrow @nogc
private fnconst(wchar) * formatPipeName(wchar[] buffer, uint counter) @trusted nothrow
private fnsize_t formatUint(wchar[] buffer, uint value) @trusted nothrow
private fnbool wouldBlock() @trusted nothrow
private fnbool wouldBlock(DWORD err) @trusted nothrow
private fnint mapWinError(DWORD winError) @trusted nothrow

Variables 1

private enumvarPIPE_READ_BUFFER_SIZE = 4096

Size of the internal read/write buffer for overlapped I/O.