TaskScheduler class

Schedules async tasks under a fixed concurrency cap, dispatching the highest-priority waiter whenever a slot opens. Higher schedule priority values run first; equal priorities preserve submission order.

Constructors

TaskScheduler({required int concurrency})
Creates a scheduler that runs at most concurrency tasks concurrently. concurrency must be at least 1. Audited: 2026-06-12 11:26 EDT

Properties

concurrency int
Maximum number of tasks allowed to run at the same time.
final
hashCode int
The hash code for this object.
no setterinherited
pending int
Number of tasks waiting for a slot. Audited: 2026-06-12 11:26 EDT
no setter
running int
Number of tasks currently executing. Audited: 2026-06-12 11:26 EDT
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
schedule<T>(ScheduledTask<T> task, {int priority = 0}) Future<T>
Schedules task to run when a slot is free, returning a future that completes with its result (or its error — a failed task never stalls the scheduler; the slot is always released). Higher priority runs sooner.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited