Preliminary. ThinkMeta ConcurrentTasks and this documentation are preliminary; everything is subject to change.

API reference / Async I/O

AsyncIoRequestBase class

One overlapped I/O operation.

Use
import ThinkMeta.ConcurrentTasks.AsyncIo.AsyncIoRequest;
Namespace
ThinkMeta::ConcurrentTasks::AsyncIo

Syntax

class AsyncIoRequestBase : private OVERLAPPED

Remarks

Owns the OVERLAPPED that is passed to the Win32 call and is told the result through RequestCompleted. While an operation is pending, the request and the buffer of the operation must stay alive: the kernel writes into the OVERLAPPED and the I/O thread reports the result to the request. The request does not own the buffer. A request carries one operation at a time; call Reset before reusing it for the next one.

See also

AsyncIoRequest, AsyncIoRequestCompleted

Constructors

AsyncIoRequestBaseprotected

Creates an empty request.

Syntax

AsyncIoRequestBase() noexcept;

Remarks

The OVERLAPPED is zeroed (offset 0) and no bytes are transferred.

Methods

FromOverlapped

Maps an OVERLAPPED back to its request.

Syntax

static AsyncIoRequestBase* FromOverlapped(OVERLAPPED* overlapped) noexcept;

Parameters

overlappedOVERLAPPED*
An OVERLAPPED that belongs to a request, e.g. as dequeued from the port.

Return value

Type: AsyncIoRequestBase*

The request that contains overlapped.

Remarks

Pass only an OVERLAPPED obtained from GetOverlapped of a request.

See also

AsyncIoRequestCompleted

GetTransferredBytes

Bytes the completed operation transferred (as stored by RequestCompleted).

Syntax

DWORD GetTransferredBytes() const noexcept;

Return value

Type: DWORD

The transferred bytes; 0 before completion and after Reset.

SetTransferredBytes

Stores the transferred byte count; for use by RequestCompleted.

Syntax

void SetTransferredBytes(DWORD transferredBytes) noexcept;

Parameters

transferredBytesDWORD
Bytes the operation transferred.

OnRequestCompletedImmediately

Completes the request on the calling thread when the Win32 call succeeded at once.

Syntax

void OnRequestCompletedImmediately(DWORD transferredBytes) noexcept;

Parameters

transferredBytesDWORD
Bytes the Win32 call reported as transferred.

Remarks

The core associates every handle with FILE_SKIP_COMPLETION_PORT_ON_SUCCESS, so an operation that succeeds immediately posts no completion packet: the issuer must complete the request itself, which is what this does (RequestCompleted with ERROR_SUCCESS). Do not call it for a pending operation (ERROR_IO_PENDING) - that one is completed by the I/O thread.

See also

RequestCompleted

RequestCompleted

Called exactly once per operation with its result.

Syntax

virtual void RequestCompleted(DWORD error, DWORD bytesTransferred) noexcept = 0;

Parameters

errorDWORD
The operation's Win32 error code; ERROR_SUCCESS when it succeeded.
bytesTransferredDWORD
Bytes the operation transferred.

Remarks

Runs on the core's single I/O thread for a pending operation, or on the issuing thread through OnRequestCompletedImmediately (or when the issuer reports an immediate failure itself). Keep it short and do not block or suspend in it: it holds up every other completion of the process. A waiter may destroy the request as soon as it is signalled, so signalling must be the last access to the request.

See also

AsyncIoRequestCompleted

Reset

Prepares the request for the next operation.

Syntax

virtual void Reset() noexcept;

Remarks

Zeroes the OVERLAPPED (including the offset) and the transferred bytes. Only while no operation is pending.

GetOverlapped

The OVERLAPPED to pass to the Win32 call (ReadFile, WSARecv, ...).

Syntax

OVERLAPPED& GetOverlapped() noexcept;

Return value

Type: OVERLAPPED&

The request's own OVERLAPPED; it lives as long as the request.

The OVERLAPPED to pass to the Win32 call (ReadFile, WSARecv, ...).

Syntax

const OVERLAPPED& GetOverlapped() const noexcept;

Return value

Type: const OVERLAPPED&

The request's own OVERLAPPED; it lives as long as the request.

Generated from ThinkMeta.ConcurrentTasks.API @ 137ec1d (2026-10-17).