BloomScheduler class
Cooperative priority-based time-slicing scheduler for Bloom JS Native.
Coordinates task execution across TaskPriority levels (immediate, userBlocking, normal, low, idle) in bounded slices (defaulting to frameBudgetMs milliseconds), yielding to the event loop between slices so the browser can paint and process user input.
In pure-Dart / VM / SSR environments, yielding uses portable macrotask timers (DefaultSchedulerHost). In browser environments, custom hosts hooking into rAF / idle callbacks can be installed via setHost.
final task = BloomScheduler.schedule(() async {
for (final item in largeDataset) {
processItem(item);
if (BloomScheduler.shouldYield()) {
await BloomScheduler.yieldNow();
}
}
}, priority: TaskPriority.low);
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- currentHost → SchedulerHost
-
Current platform scheduler host.
no setter
- frameBudgetMs ↔ int
-
Time slice budget in milliseconds (default 5ms) before yielding to the host event loop.
getter/setter pair
- pendingTaskCount → int
-
Total number of active, non-cancelled pending tasks across all priority tiers.
no setter
Static Methods
-
flush(
) → Future< void> - Flushes all pending tasks in the queue until empty.
-
resetHost(
) → void - Resets the scheduler host back to DefaultSchedulerHost.
-
schedule<
T> (FutureOr< T> task(), {TaskPriority priority = TaskPriority.normal}) → SchedulerTask<T> -
Schedules
taskfor execution at the specifiedpriority. -
setHost(
SchedulerHost host) → void - Replaces the current scheduler host platform hook.
-
shouldYield(
{int? customBudgetMs}) → bool - Checks whether the current time slice has exceeded frameBudgetMs or a higher-priority task is queued.
-
yieldNow(
) → Future< void> - Yields the current time slice to the host event loop, resuming when the host turns.