WaitableTask class
A Task that others can wait for until it has exited.
- Use
import ThinkMeta.ConcurrentTasks.Tasks.WaitableTask;- Namespace
ThinkMeta::ConcurrentTasks::Tasks- Inherits
Task
Syntax
using WaitableTask = _WaitableTask<SuspensionKind::Multiple>;
using WaitableTask_s = _WaitableTask<SuspensionKind::Single>;Template parameters
_SuspensionKindSuspensionKindSuspensionKind::Multiple: any number of waiting tasks;SuspensionKind::Single: at most one waiting task at a time, cheaper, with timeouts.
Remarks
Wait suspends the caller until the task's ITask::Run has returned and OnTaskExited has been called. Derive from it and implement Run. WaitableTask allows any number of waiting tasks; WaitableTask_s allows at most one task waiting at a time, is cheaper and accepts a timeout. The waiting side must be a task or a thread converted with ConvertThreadToTask. After the first exit every Wait returns at once: an object is meant to run once.
See also
Names
| Name | Description |
|---|---|
WaitableTask |
WaitableTask for any number of waiting tasks.
|
WaitableTask_s |
WaitableTask for at most one waiting task at a time.
Cheaper, and |
Methods
Wait
Suspends the calling task until this task has exited.
Syntax
void Wait() noexcept;Remarks
Returns at once if it has exited already.
See also
_s only
Suspends the calling task until this task has exited, with a timeout.
Syntax
[[nodiscard]] bool Wait(Duration timeout) noexcept;Parameters
timeoutDuration- Longest time to wait, as a
Duration;Duration::Infinitewaits without a timeout.
Return value
Type: bool
true if the task has exited; false if the wait timed out.
Remarks
WaitableTask_s only.
See also
TryWait
Returns whether the task has exited, without waiting.
Syntax
[[nodiscard]] bool TryWait() noexcept;Return value
Type: bool
true if the task has exited; otherwise false.
See also
OnTaskExited
Called by the core when the task has exited.
Syntax
void OnTaskExited() noexcept override;Remarks
Releases the waiting tasks, then tells the notify callback (e.g. a Synchronization::TaskGroup), if any. An override must call this version and must not touch the object after it.
Generated from ThinkMeta.ConcurrentTasks.API @ 137ec1d (2026-10-17).