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

API reference / Async I/O

WaitableAsyncSocketIoRequest class

A socket request a task can wait on until the operation completes.

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

Syntax

using WaitableAsyncSocketIoRequest =
    _WaitableAsyncSocketIoRequest<AsyncSocketIoRequest, SuspensionKind::Multiple>;
using WaitableAsyncSocketIoRequest_s =
    _WaitableAsyncSocketIoRequest<AsyncSocketIoRequest, SuspensionKind::Single>;
using WaitableAsyncSocketRecvIoRequest =
    _WaitableAsyncSocketIoRequest<
        AsyncSocketRecvIoRequest,
        SuspensionKind::Multiple
    >;
using WaitableAsyncSocketRecvIoRequest_s =
    _WaitableAsyncSocketIoRequest<AsyncSocketRecvIoRequest, SuspensionKind::Single>;

Template parameters

_AsyncSocketIoRequestAsyncSocketIoRequestType
The request built on: AsyncSocketIoRequest, or AsyncSocketRecvIoRequest to also capture the result flags of a receive.
_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 the WaitableAsyncSocketIoRequest, WaitableAsyncSocketIoRequest_s, WaitableAsyncSocketRecvIoRequest and WaitableAsyncSocketRecvIoRequest_s variants below. The Single variant allows one waiting task and timed waits; once its Wait returns, nothing in the library touches the object again, so it may live on the waiting task's stack and be destroyed right away. The Multiple variant allows any number of waiting tasks but no timeout.

Names

NameDescription
WaitableAsyncSocketIoRequest Waitable socket request, any number of waiting tasks (Multiple), no timed wait.
WaitableAsyncSocketIoRequest_s Waitable socket request, at most one waiting task (Single); cheaper, allows timed waits.
WaitableAsyncSocketRecvIoRequest Waitable receive request, any number of waiting tasks (Multiple).

Captures the result flags (see AsyncSocketRecvIoRequest).

WaitableAsyncSocketRecvIoRequest_s Waitable receive request, at most one waiting task (Single); allows timed waits.

Captures the result flags (see AsyncSocketRecvIoRequest).

Constructors

WaitableAsyncSocketIoRequest

Windows only

Creates an idle request.

Syntax

Windows only

Creates an idle receive request.

Syntax

explicit WaitableAsyncSocketIoRequest(SOCKET socket) noexcept;

Parameters

socketSOCKET
The socket the operation runs on; used to query the result flags.

Linux only

Creates an idle request.

Syntax

WaitableAsyncSocketIoRequest() noexcept = default;

Methods

RequestCompleted

Records the result, then sets the event.

Syntax

void RequestCompleted(
    AsyncIoRequestBase::CompletionError error,
    AsyncIoRequestBase::ByteCount bytesTransferred
) noexcept override;

Parameters

errorAsyncIoRequestBase::CompletionError
The operation's own error code; 0 on success.
bytesTransferredAsyncIoRequestBase::ByteCount
Bytes the operation transferred.

Remarks

Setting the event is the last access on behalf of the completion.

Reset

Re-arms the request for another operation.

Syntax

void Reset() noexcept override;

Remarks

Only after the previous operation has completed.

TryWait

true if the operation has completed; never blocks.

Syntax

bool TryWait() noexcept;

Return value

Type: bool

true if the operation has completed; false while it is still in flight.

See also

Wait

Wait

Suspends the calling task until the operation has completed.

Syntax

void Wait() noexcept;

Remarks

Task only.

See also

TryWait

_s only

Waits for the completion with a timeout.

Syntax

[[nodiscard]] WaitStatus Wait(Duration timeout) noexcept;

Parameters

timeoutDuration
How long to wait at most.

Return value

Type: WaitStatus

WaitStatus::Signaled if the operation has completed; WaitStatus::TimedOut if the timeout expired first; WaitStatus::Cancelled if the waiting task was cancelled (CancelTask).

Remarks

Single waiter only. Task only; needs EnableTimers for a finite timeout (without it the wait has no limit). A timeout or cancel does not cancel the operation: the request must stay alive until it has completed.

See also

AsyncSocket::CancelAsyncRequest

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