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.

Use
import ThinkMeta.ConcurrentTasks.Synchronization.SuspendableBase;
Namespace
ThinkMeta::ConcurrentTasks::Synchronization
Inherits
ISuspendCallback

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).

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.

See also

ResumeNext, ResumeNonReentrant

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.

Resumes a task that the caller has already claimed.

Syntax

static void Resume(SuspendedTask suspendedTask) noexcept;

Parameters

suspendedTaskSuspendedTask
The claimed handle; nullptr is ignored.

Remarks

Calls ResumeTask.

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.

ResumeNonReentrantprotected

Resumes the tasks suspended right now, but not those that suspend meanwhile.

Syntax

void ResumeNonReentrant() noexcept;

Remarks

Like Resume, but first moves the suspended tasks to a local stack, so that tasks which suspend again while the loop runs are not resumed by this call. Reverses the order: the earliest suspended task is resumed first.

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]] unsigned short GetNumSuspendedTasks() const noexcept;

Return value

Type: unsigned short

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

Remarks

A snapshot (QueryDepthSList).

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

bool SuspendFor(Duration timeout) noexcept;

Parameters

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

Return value

Type: bool

true if a resumer ended the wait; false if it timed out (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 @ 137ec1d (2026-10-17).