Waitable class
Turns a non-blocking TryWait() into a suspending Wait().
- Use
import ThinkMeta.ConcurrentTasks.Synchronization.Waitable;- Namespace
ThinkMeta::ConcurrentTasks::Synchronization- Inherits
Suspendable
Syntax
template <SuspensionKind _SuspensionKind, class T>
class Waitable
: protected Suspendable<_SuspensionKind, Waitable<_SuspensionKind, T>>Template parameters
_SuspensionKindSuspensionKindSuspensionKind::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.
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. 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
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. Task or converted thread only; no timeout.
_s only
Waits with a time limit.
Syntax
[[nodiscard]] bool Wait(this auto& self, Duration timeout) noexcept;Parameters
timeoutDuration- The longest time to wait. Needs
EnableTimers; without it the wait has no limit.
Return value
Type: bool
true if TryWait succeeded at once or a resumer let the task pass; false if it timed out, the task then no longer waits on the object.
Remarks
Only for the single-waiter (_s) variants. Task or converted thread only.
See also
Generated from ThinkMeta.ConcurrentTasks.API @ 137ec1d (2026-10-17).