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

API reference / Async I/O

WaitableAsyncFileIoRequest class

A file request whose completion a task can wait for.

Use
import ThinkMeta.ConcurrentTasks.AsyncIo.AsyncFileIoRequest;
Namespace
ThinkMeta::ConcurrentTasks::AsyncIo
Inherits
AsyncFileIoRequest

Syntax

using WaitableAsyncFileIoRequest =
    _WaitableAsyncFileIoRequest<SuspensionKind::Multiple>;
using WaitableAsyncFileIoRequest_s =
    _WaitableAsyncFileIoRequest<SuspensionKind::Single>;

Template parameters

_SuspensionKindSuspensionKind
SuspensionKind::Multiple: any number of tasks may wait; SuspensionKind::Single: at most one waiting task, cheaper, allows a timeout.

Remarks

A manual-reset event is set when the operation completes. Use WaitableAsyncFileIoRequest (any number of waiting tasks) or WaitableAsyncFileIoRequest_s (at most one waiting task). Wait suspends the calling task (its thread runs other tasks meanwhile); a plain OS thread must first call ConvertThreadToTask (Core.h). The event is set on the completing thread (I/O thread, or the issuer for an immediate completion), as the last access of the completion: once Wait returns, the request may be destroyed at once, which allows requests in a task's stack frame. An operation that failed to be issued (an error other than ERROR_IO_PENDING) never completes on its own: do not wait for it, or complete it with RequestCompleted yourself. Never destroy the request while an operation is pending.

See also

AsyncFileIoRequest

Names

NameDescription
WaitableAsyncFileIoRequest Waitable file request on which any number of tasks may wait.
WaitableAsyncFileIoRequest_s Waitable file request with at most one waiting task.

Cheaper, and allows WaitableAsyncFileIoRequest::Wait with a timeout.

Methods

RequestCompleted

Stores the result, then sets the event (the last access to the request).

Syntax

void RequestCompleted(DWORD error, DWORD bytesTransferred) noexcept override;

Parameters

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

Reset

Prepares the request for the next operation and resets the event.

Syntax

void Reset() noexcept override;

Remarks

Not while an operation is pending.

TryWait

true if the operation has completed; never suspends.

Syntax

bool TryWait() noexcept;

Return value

Type: bool

true if the operation has completed; false if it is still pending.

See also

Wait

Wait

Suspends the calling task until the operation has completed.

Syntax

void Wait() noexcept;

See also

TryWait

_s only

Suspends the calling task until the operation has completed or the timeout has passed.

Syntax

bool Wait(Duration timeout) noexcept;

Parameters

timeoutDuration
How long to wait at most.

Return value

Type: bool

true if the operation has completed; false if it timed out.

Remarks

WaitableAsyncFileIoRequest_s only. Needs EnableTimers, else the wait has no limit. A timeout does not cancel the operation: it stays pending and the request must stay alive until it completes (cancel it with CancelIoEx and Wait, as AsyncFile::Read does).

See also

TryWait

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