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

API reference / Synchronization

SuspendableBase class

Keeps the tasks suspended on one synchronization object and resumes them.

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

Syntax

template <SuspensionKind _SuspensionKind> class SuspendableBase

Template parameters

_SuspensionKindSuspensionKind
SuspensionKind::Multiple: any number of suspended tasks; SuspensionKind::Single: at most one suspended task at a time, cheaper, with timeouts.

Remarks

Bottom building block of the synchronization primitives, on top of Core.h SuspendTask. Suspend / SuspendFor must be called from a task or from an OS thread converted with ConvertThreadToTask; the resume members may be called from any thread. Destroy the object only when no task is suspended on it any more (asserted in Debug).

See also

SuspensionKind, Suspendable

Constructors

SuspendableBaseprotected

Creates the object with no suspended task.

Syntax

SuspendableBase() noexcept = default;

Remarks

Works anywhere, also for global and static objects.

~SuspendableBaseprotected

Destroys the object.

Syntax

~SuspendableBase() noexcept;

Remarks

No task may be suspended on the object any more (asserted in Debug), and no resume or suspend callback may still be inside it: a waiter's own callback re-checks the object after it published the task, and a signal that is stored before the list of waiters is taken still takes that list after a waiter may have passed. The return of a wait alone is therefore no licence to destroy a Multiple object; the Single ("_s") variants are built for that.

Methods

Suspendprotected

Suspends the calling task.

Syntax

void Suspend() noexcept;

Remarks

The core then calls ISuspendCallback::OnSuspended. Task or converted thread only.

Resumeprotected

Resumes every suspended task.

Syntax

void Resume() noexcept;

Remarks

Covers the tasks suspended right now, not those that suspend while they are resumed: the list is taken in one operation, and the object is not touched again afterwards. So a resumed task may suspend on the object again without being resumed a second time by this call (a group reused for the next round, an event reset and waited for again).

See also

ResumeNext

Claims and resumes the suspended task.

Syntax

bool Resume() noexcept;

Return value

Type: bool

true if a task was resumed; false if the slot was empty.

ResumeNextprotected

Resumes one suspended task.

Syntax

bool ResumeNext() noexcept;

Return value

Type: bool

true if a task was resumed; false if there was none.

Remarks

The most recently suspended task is resumed.

See also

Resume

Hands a lock over to one suspended task and resumes it.

Syntax

bool ResumeNext(std::atomic<TaskHandle>& tc) noexcept;

Parameters

tcstd::atomic<TaskHandle>&
Receives the popped task (or nullptr) before the task is resumed; CriticalSection passes its owner field.

Return value

Type: bool

true if a task was resumed; false if there was no suspended task.

IsSuspendedprotected

Tells whether any task is suspended.

Syntax

[[nodiscard]] bool IsSuspended() const noexcept;

Return value

Type: bool

true if at least one task is suspended (a snapshot; may change at once).

GetNumSuspendedTasksprotected

Returns the number of suspended tasks.

Syntax

[[nodiscard]] std::uint16_t GetNumSuspendedTasks() const noexcept;

Return value

Type: std::uint16_t

The number of tasks suspended on the object, at most 65535.

Remarks

A snapshot of the stack's depth, which counts modulo 65536.

AddSuspendedTaskprotected

Publishes a suspended task.

Syntax

void AddSuspendedTask(SuspendedTask suspendedTask) noexcept;

Parameters

suspendedTaskSuspendedTask
The handle ISuspendCallback::OnSuspended received; not nullptr.

Remarks

SuspendForprotected

Suspends the calling task with a time limit.

Syntax

WaitStatus SuspendFor(Duration timeout) noexcept;

Parameters

timeoutDuration
Longest time to stay suspended, as a Duration; Duration::Infinite waits without a timeout.

Return value

Type: WaitStatus

How the wait ended: WaitStatus::Signaled by a resumer, WaitStatus::TimedOut or WaitStatus::Cancelled (see SuspendTaskFor).

See also

Suspend

SetSuspendedTaskprotected

Records the suspended task.

Syntax

void SetSuspendedTask(SuspendedTask suspendedTask) noexcept;

Parameters

suspendedTaskSuspendedTask
The handle ISuspendCallback::OnSuspended received; not nullptr.

Remarks

Called from ISuspendCallback::OnSuspended. The slot must be empty: at most one task may be suspended on the object at a time (asserted in Debug).

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