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

API reference / Synchronization

Waitable class

Turns a non-blocking TryWait() into a suspending Wait().

On this page
Use
import ThinkMeta.ConcurrentTasks.Synchronization.Waitable;
Namespace
ThinkMeta::ConcurrentTasks::Synchronization
Inherits
Suspendable
Platforms
Windows, Linux

Syntax

template <SuspensionKind _SuspensionKind, class T>
class Waitable
    : protected Suspendable<_SuspensionKind, Waitable<_SuspensionKind, T>>

Template parameters

_SuspensionKindSuspensionKind
SuspensionKind::Multiple: any number of waiting tasks; SuspensionKind::Single: at most one waiting task at a time, with timeouts.
Tclass
The primitive built on it; provides a public bool TryWait() (non-blocking, may consume the signal) and a Resume() that resumes the suspended task(s) the passed TryWait stands for. A T whose condition stays observable after a resume (a manual-reset event, a task group's count) declares static constexpr bool WaitRechecks = true: its Wait then checks TryWait() again after every resume and suspends again if the condition no longer holds. A T whose resume hands the signal to the resumed task (an auto-reset event, a semaphore) does not, since its TryWait() would find nothing after a legitimate resume.

Remarks

Wait tries T::TryWait() first and suspends only if that fails; when a task suspends, TryWait() is checked again and T::Resume() is called if it now succeeds. That re-check resumes every task suspended at that moment, so with SuspensionKind::Multiple a task can be resumed although the condition was taken back meanwhile (a Reset between a Set and the re-check); a T with WaitRechecks absorbs that by waiting again. With SuspensionKind::Single the same happens when the waiter reuses the object (a TaskGroup_s of the next round) while the re-check of its previous wait is still running. Wait must be called from a task or from an OS thread converted with ConvertThreadToTask; it suspends the caller if TryWait fails. For SuspensionKind::Single, at most one task may wait at a time.

See also

Suspendable

Methods

Wait

Waits until the primitive lets the calling task pass.

Syntax

void Wait(this auto& self) noexcept;

Remarks

Returns at once if T::TryWait() succeeds, otherwise suspends the calling task until a resumer lets it pass (and, with WaitRechecks, until TryWait() holds after the resume). Task or converted thread only; no timeout, and a CancelTask does not end it.

_s only

Waits with a time limit.

Syntax

[[nodiscard]] WaitStatus Wait(this auto& self, Duration timeout) noexcept;

Parameters

timeoutDuration
The longest time to wait. Needs EnableTimers; without it, or with Duration::Infinite, the wait has no limit.

Return value

Type: WaitStatus

WaitStatus::Signaled if TryWait succeeded at once or a resumer let the task pass (with WaitRechecks: and TryWait() held after the resume); WaitStatus::TimedOut if it timed out; WaitStatus::Cancelled if the task was cancelled (CancelTask). Unless signaled, the task no longer waits on the object.

Remarks

Only for the single-waiter (_s) variants. Task or converted thread only.

See also

Duration

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