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

API reference / Core

ITaskScheduler interface

A scheduler: a set of OS threads that run tasks as fibers.

Use
#include <ThinkMeta.ConcurrentTasks/Core.h>
Namespace
ThinkMeta::ConcurrentTasks

Syntax

Remarks

Created by CreateTaskScheduler, released by Destroy. User code needs AddTask, AddTimedTask, Start, Stop and Destroy. SuspendTask, YieldTask, ResumeTask and StealTaskOrSuspend are core-internal; use the free functions of the same name, which find the right scheduler.

See also

GetTaskScheduler

Methods

AddTask

Queues a task to run on this scheduler.

Syntax

virtual void AddTask(
    ITask* task,
    TaskPriority priority = TaskPriority::Default
) noexcept = 0;

Parameters

taskITask*
The task to run; required. Owned by the caller and must stay valid until its INotifyTaskStateChange::OnTaskExited has been called.
priorityTaskPriority
TaskPriority::Default inherits the calling task's priority.Default: TaskPriority::Default

Remarks

May be called from any thread or task, also before Start (the task then runs once Start has been called). Never blocks; the queue capacity must cover the runnable tasks (see SchedulerInfo::taskQueueCapacity). A task may be added again only once its INotifyTaskStateChange::OnTaskExited has been called.

See also

AddTimedTask

Start

Starts the scheduler threads.

Syntax

virtual void Start() noexcept = 0;

Remarks

See also

Stop

Stop

Stops the scheduler and blocks until all its threads have exited.

Syntax

virtual void Stop() noexcept = 0;

Remarks

Does nothing if the scheduler is not running. Tasks still queued or suspended are not run to completion, so wait for your tasks before stopping. Must be called from outside the scheduler's own threads.

See also

Start

SuspendTask

Suspends the calling task.

Syntax

virtual void SuspendTask(ISuspendCallback* callback) noexcept = 0;

Parameters

callbackISuspendCallback*
Receives the task's handle once the task is off the processor; required, and must stay valid until ISuspendCallback::OnSuspended has returned.

Remarks

Core-internal: user code calls the free function ThinkMeta::ConcurrentTasks::SuspendTask, which forwards to the calling task's own scheduler. Called directly, it must be the scheduler running the calling task.

YieldTask

Gives up the processor without suspending.

Syntax

virtual void YieldTask(YieldFlags yieldFlags = YieldFlags::Default) noexcept = 0;

Parameters

yieldFlagsYieldFlags
How to yield; see YieldFlags.Default: YieldFlags::Default

Remarks

Core-internal: user code calls the free function ThinkMeta::ConcurrentTasks::YieldTask. Called directly, it must be the scheduler running the calling task; the task stays runnable (see YieldFlags).

ResumeTask

Makes a suspended task runnable again.

Syntax

virtual void ResumeTask(SuspendedTask suspendedTask) noexcept = 0;

Parameters

suspendedTaskSuspendedTask
Handle received by ISuspendCallback::OnSuspended; nullptr is ignored.

Remarks

Core-internal: user code calls the free function ThinkMeta::ConcurrentTasks::ResumeTask, which finds the right scheduler and also settles the race with a SuspendTaskFor timeout. Called directly, suspendedTask must have been suspended on this scheduler; a handle from another scheduler must never be passed. Callable from any thread or task; nullptr is ignored.

StealTaskOrSuspend

Fetches the next new task for an idle task fiber; internal to the core.

Syntax

virtual ITask* StealTaskOrSuspend(TaskPriority& taskPriority) noexcept = 0;

Parameters

taskPriorityTaskPriority&
Receives the returned task's priority.

Return value

Type: ITask*

The task, or nullptr after the fiber was switched away (suspended) because a resumed task or nothing is runnable.

Remarks

Core-internal: never called by user code.

Destroy

Releases a scheduler created by CreateTaskScheduler.

Syntax

virtual void Destroy() noexcept = 0;

Remarks

Use it instead of delete.

AddTimedTask

Adds a task after a delay.

Syntax

virtual bool AddTimedTask(
    ITask* task,
    TaskPriority priority,
    Duration delay
) noexcept = 0;

Parameters

taskITask*
The task to start; it must return storage from ITask::GetTimerData. Owned by the caller and must stay valid until its INotifyTaskStateChange::OnTaskExited has been called.
priorityTaskPriority
Priority the task runs with; TaskPriority::Default inherits the calling task's priority.
delayDuration
Time from now until the task is queued, as a Duration.

Return value

Type: bool

true if the task is waiting to start; false if timers are not enabled, the task has no ITask::GetTimerData, it is being cancelled, or the scheduler cannot start tasks by time (SchedulerKind::TaskSwap).

Remarks

Needs EnableTimers. Called again before the task has started, it moves the start. Like AddTask, a task may be added again only once it has exited.

See also

CancelTimedTask, ScheduleTimedTask

Generated from ThinkMeta.ConcurrentTasks.API @ 137ec1d (2026-10-17).