LocalScheduler class
Owns a scheduler whose tasks run on the thread that calls Run.
On this page
- Use
import ThinkMeta.ConcurrentTasks.Schedulers.LocalScheduler;- Namespace
ThinkMeta::ConcurrentTasks::Schedulers- Platforms
- Windows, Linux
Syntax
class LocalSchedulerRemarks
Add tasks, then call Run: it runs them on the calling thread and returns once every task of the scheduler has ended, including those the tasks add and those started by time. While all of them wait, the thread sleeps. The tasks never run on another thread. The thread that calls Run owns the scheduler: only it adds tasks, before Run or from the scheduler's tasks. Tasks may be resumed from any thread, so they can hand work to another scheduler and wait for it (Tasks::Task::Schedule, Tasks::RunAndWait, Synchronization::TaskGroup_s), sleep and wait with a timeout. The order is that of the default scheduler. Usage rules: call Run on a plain thread, never from a task or on a converted thread. Create and destroy the scheduler on that thread; it may be destroyed as soon as Run has returned, but never by one of its tasks. A task that waits for something only the caller of Run can provide waits for ever. Performance is not this scheduler's aim; it is about where tasks run.
See also
Constructors
LocalScheduler
Creates the scheduler, on the thread that will call Run.
Syntax
explicit LocalScheduler(
std::uint32_t taskStackSize = 0,
std::uint32_t taskQueueCapacity = 0
) noexcept;Parameters
taskStackSizestd::uint32_t- Stack size per task in bytes;
0is the platform's default (seeSchedulerInfo::taskStackSize).Default:0 taskQueueCapacitystd::uint32_t- Capacity of each task queue;
0isDefaultTaskQueueCapacity(seeSchedulerInfo::taskQueueCapacity).Default:0
~LocalScheduler
Destroys the scheduler.
Syntax
~LocalScheduler();Remarks
Only after Run has returned and no task is left.
Methods
operatorbool
Returns whether the scheduler was created.
Syntax
explicit operator bool() const noexcept;Get
Returns the core's scheduler.
Syntax
ILocalScheduler* Get() const noexcept;Return value
Type: ILocalScheduler*
operator->
Returns the core's scheduler.
Syntax
ILocalScheduler* operator->() const noexcept;Return value
Type: ILocalScheduler*
operatorITaskScheduler&
Returns the scheduler as a target for tasks, e.g. for Tasks::Task::Schedule.
Syntax
operator ITaskScheduler&() const noexcept;AddTask
Adds a task; it runs in the next or the current Run.
Syntax
void AddTask(ITask* task, TaskPriority priority = TaskPriority::Default) noexcept;Parameters
taskITask*- The task; must stay valid until it has exited.
priorityTaskPriorityTaskPriority::Defaultinherits the calling task's priority.Default:TaskPriority::Default
Remarks
Only on the thread that calls Run: before Run, or from a task of this scheduler.
See also
Run
Runs the tasks on the calling thread and blocks it until none is left.
Syntax
void Run() noexcept;Remarks
Only on a plain thread, never from a task or on a converted thread.
See also
Generated from ThinkMeta.ConcurrentTasks.API @ 8da5722 (2026-11-16).