Classes | Scheduling

Scheduler : Object

schedules functions to be evaluated in the future


A Scheduler can be used to schedule and reschedule functions to be evaluated at a specific time-point. The Scheduler's time needs to be advanced manually. In most cases you will probably want to use a Clock (e.g. TempoClock, SystemClock, AppClock) instead, in which the march of time is handled for you.

Class Methods, drift: false, recursive: true)



A clock, like SystemClock.


If true, -sched will schedule tasks relative to the current absolute time ( Main.elapsedTime ), otherwise to the current logical time of the scheduler ( -seconds ).


Sets -recursive.

Inherited class methods

Instance Methods


Schedules the task immediately. Equivalent to sched(0, task).

.sched(delta, item)

Schedule the task at delta seconds relative to the current time, as defined by the drift argument of the constructor.

Regardless of what time a task is scheduled, it will only be awaken the next time -seconds is set.

.schedAbs(time, item)

Schedule the task at absolute time in seconds.


Advance the current logical time by delta seconds. Has same effect as setting -seconds.


.seconds = newSeconds

The current logical time of the scheduler.

Setting a new time will wake up (evaluate) any tasks scheduled within that time; a task that returns a new time will be rescheduled accordingly.


Returns whether the scheduling queue is empty.


Clears the scheduling queue



The instance of PriorityQueue used internally as scheduling queue.


.recursive = value

If waking up items results in new items being scheduled, but some of them are already expired (scheduled at current time or earlier), this variable determines whether those items will be awaken as well in the same call to -seconds.

Inherited instance methods