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

API reference / Async I/O

AsyncIoRequestBase class

One asynchronous I/O operation.

On this page
Use
import ThinkMeta.ConcurrentTasks.AsyncIo.AsyncIoRequest;
Namespace
ThinkMeta::ConcurrentTasks::AsyncIo
Platforms
Windows, Linux

Syntax

class AsyncIoRequestBase : private _NativeIoRequest

Remarks

Owns the platform's request structure - the OVERLAPPED passed to the Win32 call on Windows, the IoRequest passed to SubmitIo elsewhere - 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 works with them 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 request structure is zeroed (offset 0) and no bytes are transferred.

Methods

SetTransferredBytesprotected

Stores the transferred byte count; for use by RequestCompleted.

Syntax

void SetTransferredBytes(ByteCount transferredBytes) noexcept;

Parameters

transferredBytesByteCount
Bytes the operation transferred.

FromNativeRequest

Maps the platform's request structure back to its request.

Syntax

static AsyncIoRequestBase* FromNativeRequest(_NativeIoRequest* request) noexcept;

Parameters

request_NativeIoRequest*
An OVERLAPPED (Windows) or IoRequest (elsewhere) that belongs to a request, as the core hands it to the completion routine.

Return value

Type: AsyncIoRequestBase*

The request that contains request.

Remarks

Pass only a structure obtained from GetOverlapped or GetIoRequest of a request.

See also

AsyncIoRequestCompleted

GetTransferredBytes

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

Syntax

ByteCount GetTransferredBytes() const noexcept;

Return value

Type: ByteCount

The transferred bytes; 0 before completion and after Reset.

OnRequestCompletedImmediately

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

Syntax

void OnRequestCompletedImmediately(ByteCount transferredBytes) noexcept;

Parameters

transferredBytesByteCount
Bytes the 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 0, success). Do not call it for a pending operation - that one is completed by the I/O thread. Outside Windows every submitted operation completes on the I/O thread, so only an issuer that does the work itself has a use for it.

See also

RequestCompleted

RequestCompleted

Called exactly once per operation with its result.

Syntax

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

Parameters

errorCompletionError
The operation's error code; 0 when it succeeded. A Win32 error code on Windows, an errno elsewhere.
bytesTransferredByteCount
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 request structure (including the offset) and the transferred bytes. Only while no operation is pending.

GetOverlappedWindows only

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.

GetIoRequestLinux only

The IoRequest to fill and pass to SubmitIo.

Syntax

IoRequest& GetIoRequest() noexcept;

Return value

Type: IoRequest&

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

The IoRequest to fill and pass to SubmitIo.

Syntax

const IoRequest& GetIoRequest() const noexcept;

Return value

Type: const IoRequest&

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

Types

ByteCount

A byte count of one operation, on every platform.

Syntax

using ByteCount = std::uint32_t;

CompletionError

The error code a completion reports: a Win32 error code on Windows, an errno elsewhere.

Syntax

using CompletionError = _CompletionError;

Generated from ThinkMeta.ConcurrentTasks.API @ c7663c4 (2026-11-19).