Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Scheduler

abstract scheduler class, interface for concrete deadline and fixed priority schedulers

Hierarchy

Index

Constructors

constructor

  • constructor, setting up a scheduler object

    Parameters

    • Default value config: Object = DEFAULT_SCHEDULER_CONFIG

      set to DEFAULT_SCHEDULER_CONFIG, may use any other values

    Returns Scheduler

Properties

NPCS

NPCS: boolean

Flag indicates a non-preemptive critical section

RTJS_BUDGET

RTJS_BUDGET: number

Number of preemption points that are visited before thread must actually call yield

config

mostly constant configuration options for the scheduler

Optional currentTask

currentTask: TaskState

the currently running task

Protected forceReschedule

forceReschedule: boolean

This flag forces the scheduler to reschedule immediately, before finishing the current timeslice.

Private pauses

pauses: boolean = true

number of pauses of the scheduler, may be used nestedly

printTimes

printTimes: boolean

schedulerTime

schedulerTime: number = 0

How long was the scheduler active on the executor

Private timeoutQueue

timeoutQueue: PriorityQueue<TimeoutState> = new PriorityQueue((a: TimeoutState, b: TimeoutState) => {return b.timeout > a.timeout})

Timeout queue to manage more precise timeouts

Accessors

numberOfTasks

  • get numberOfTasks(): number
  • Returns number

    the number of elements in the task queue

paused

  • get paused(): boolean

Methods

addAlarm

  • addAlarm(fn: function, delay: number, periodic?: boolean): TimeoutState
  • Add a single-short or periodic alarm function.

    Parameters

    • fn: function

      The function to be callled after the delay has passed

        • (): void
        • Returns void

    • delay: number

      The deay in miliseconds

    • Default value periodic: boolean = false

      Whether the alarm is enqueued again

    Returns TimeoutState

addTask

  • add a task to the queue of the scheduler, sends a scheduler-message to event queue after it is finished, if no task is running atm

    Parameters

    • task: Task

      the task object to enqueue

    • Optional parent: TaskState

      optional parameter, scheduler-structure for the parent task if any

    Returns void

Protected debug

  • debug(msg: any, ...optionalParams: any[]): void
  • print messages to stdout if the ''debug'' flag was set

    Parameters

    • msg: any
    • Rest ...optionalParams: any[]

    Returns void

Abstract emptyTaskQueue

  • emptyTaskQueue(): void

Abstract enqueueTask

  • enqueue a task into the queue of the scheduler (implementation dependent)

    Parameters

    Returns void

Private executeRound

  • executeRound(): void
  • if the scheduler is not paused, and there are still tasks left, run the scheduler for meanTimeToYield miliseconds

    Returns void

Protected executeTimelice

  • executeTimelice(): void
  • Execute the current thread for a single timelice

    Returns void

Protected Abstract getNextTask

Protected Abstract needsReschedule

  • needsReschedule(): boolean
  • determines whether a reschedule needs to take place

    Returns boolean

pause

  • pause(): void
  • pauses the scheduler, may be used nestedly

    Returns void

Protected prepareNextTask

  • prepareNextTask(): void
  • swaps the currently running task with a new one, uses needsReschedule()

    Returns void

repostMe

  • repostMe(): void
  • re-introduces the scheduler itself to the event loop

    Returns void

resume

  • resume(): void
  • resumes the scheduler after pausing, may be used nestedly

    Returns void

spawnTask

  • spawnTask(task: Task): void
  • Used by tasks to spawn new tasks, sets the currently running one as the parent

    Parameters

    • task: Task

      the child task

    Returns void

Private terminateTask

  • terminateTask(): void
  • terminates the currently running task

    Returns void

Generated using TypeDoc