WaitableAsyncFileIoRequest class
A file request whose completion a task can wait for.
- Use
import ThinkMeta.ConcurrentTasks.AsyncIo.AsyncFileIoRequest;- Namespace
ThinkMeta::ConcurrentTasks::AsyncIo- Inherits
AsyncFileIoRequest- Platforms
- Windows, Linux
Syntax
using WaitableAsyncFileIoRequest =
_WaitableAsyncFileIoRequest<SuspensionKind::Multiple>;
using WaitableAsyncFileIoRequest_s =
_WaitableAsyncFileIoRequest<SuspensionKind::Single>;Template parameters
_SuspensionKindSuspensionKindSuspensionKind::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: with WaitableAsyncFileIoRequest_s, once Wait returns, the request may be destroyed at once, which allows requests in a task's stack frame. With WaitableAsyncFileIoRequest it may not: its event stores the signal and then takes the waiters, so the request must stay until the completion has returned and no task waits on it any more (see Synchronization::ManualResetEvent); a request that one task waits for, as in a reader or writer loop, is a case for the _s variant. An operation that failed to be issued (an error other than Platform::Error::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
Names
| Name | Description |
|---|---|
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 |
Methods
RequestCompleted
Stores the result, then sets the event (the last access to the request).
Syntax
void RequestCompleted(
CompletionError error,
ByteCount bytesTransferred
) noexcept override;Parameters
errorCompletionError- The operation's error code;
0when it succeeded. bytesTransferredByteCount- 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
Suspends the calling task until the operation has completed.
Syntax
void Wait() noexcept;See also
_s only
Suspends the calling task until the operation has completed or the timeout has passed.
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 it timed out; WaitStatus::Cancelled if the waiting task was cancelled (CancelTask).
Remarks
WaitableAsyncFileIoRequest_s only. Needs EnableTimers, else the wait has no limit. A timeout or cancel does not cancel the operation: it stays pending and the request must stay alive until it completes (cancel it - CancelIoEx on Windows, CancelIo elsewhere - and Wait, as AsyncFile::Read does).
See also
Generated from ThinkMeta.ConcurrentTasks.API @ c7663c4 (2026-11-19).