Skip to main content Link Search Menu Expand Document (external link)

Scheduler overview

Added in v1.0.0


Table of contents


constructors

ControlledScheduler (class)

Signature

export declare class ControlledScheduler

Added in v1.0.0

scheduleTask (method)

Signature

scheduleTask(task: Task, priority: number)

Added in v1.0.0

shouldYield (method)

Signature

shouldYield(fiber: RuntimeFiber<unknown, unknown>): number | false

Added in v1.0.0

step (method)

Signature

step()

Added in v1.0.0

tasks (property)

Signature

tasks: PriorityBuckets<Task>

Added in v1.0.0

deferred (property)

Signature

deferred: boolean

Added in v1.0.0

MixedScheduler (class)

Signature

export declare class MixedScheduler {
  constructor(
    /**
     * @since 1.0.0
     */
    readonly maxNextTickBeforeTimer: number
  )
}

Added in v1.0.0

starveInternal (method)

Signature

private starveInternal(depth: number)

Added in v1.0.0

starve (method)

Signature

private starve(depth = 0)

Added in v1.0.0

shouldYield (method)

Signature

shouldYield(fiber: RuntimeFiber<unknown, unknown>): number | false

Added in v1.0.0

scheduleTask (method)

Signature

scheduleTask(task: Task, priority: number)

Added in v1.0.0

running (property)

Signature

running: boolean

Added in v1.0.0

tasks (property)

Signature

tasks: PriorityBuckets<Task>

Added in v1.0.0

SyncScheduler (class)

Signature

export declare class SyncScheduler

Added in v1.0.0

scheduleTask (method)

Signature

scheduleTask(task: Task, priority: number)

Added in v1.0.0

shouldYield (method)

Signature

shouldYield(fiber: RuntimeFiber<unknown, unknown>): number | false

Added in v1.0.0

flush (method)

Signature

flush()

Added in v1.0.0

tasks (property)

Signature

tasks: PriorityBuckets<Task>

Added in v1.0.0

deferred (property)

Signature

deferred: boolean

Added in v1.0.0

make

Signature

export declare const make: (
  scheduleTask: Scheduler['scheduleTask'],
  shouldYield?: Scheduler['shouldYield']
) => Scheduler

Added in v1.0.0

makeBatched

Signature

export declare const makeBatched: (
  callback: (runBatch: () => void) => void,
  shouldYield?: Scheduler['shouldYield']
) => Scheduler

Added in v1.0.0

makeMatrix

Signature

export declare const makeMatrix: (...record: Array<[number, Scheduler]>) => Scheduler

Added in v1.0.0

timer

Signature

export declare const timer: (ms: number, shouldYield?: Scheduler['shouldYield']) => Scheduler

Added in v1.0.0

timerBatched

Signature

export declare const timerBatched: (ms: number, shouldYield?: Scheduler['shouldYield']) => Scheduler

Added in v1.0.0

models

Scheduler (interface)

Signature

export interface Scheduler {
  shouldYield(fiber: RuntimeFiber<unknown, unknown>): number | false
  scheduleTask(task: Task, priority: number): void
}

Added in v1.0.0

Task (type alias)

Signature

export type Task = () => void

Added in v1.0.0

schedulers

defaultScheduler

Signature

export declare const defaultScheduler: Scheduler

Added in v1.0.0

utilities

defaultShouldYield

Signature

export declare const defaultShouldYield: (fiber: RuntimeFiber<unknown, unknown>) => number | false

Added in v1.0.0

utils

PriorityBuckets (class)

Signature

export declare class PriorityBuckets<T>

Added in v1.0.0

scheduleTask (method)

Signature

scheduleTask(task: T, priority: number)

Added in v1.0.0

buckets (property)

Signature

buckets: [number, T[]][]

Added in v1.0.0