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.

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

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

Creates an idle request.

Syntax

template <typename... _Args>
explicit WaitableAsyncSocketIoRequest(
    _Args&&... args
) noexcept : _AsyncSocketIoRequest(std::forward<_Args>(args)...);

Template parameters

_Argstypename...
The types of the arguments passed on to the base request's constructor.

Parameters

args_Args&&...
Nothing for a plain request; for a receive request the SOCKET the operation runs on (used to query the result flags).

Remarks

A receive request takes the socket the operation runs on.

Methods

RequestCompleted

Records the result, then sets the event.

Syntax

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

Parameters

errorDWORD
The operation's own Win32/WSA error code; ERROR_SUCCESS (0) on success.
bytesTransferredDWORD
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

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 the timeout expired first.

Remarks

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

See also

AsyncSocket::CancelAsyncRequest

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