Scheduler:
Filter:
Classes | Scheduling

Scheduler : Object

schedules functions to be evaluated in the future
Source: Clock.sc

Description

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

Scheduler.new(clock, drift: false, recursive: true)

Arguments:

clock

A clock, like SystemClock.

drift

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

recursive

Sets -recursive.

Inherited class methods

Instance Methods

.play(task)

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(delta)

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

.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.

.isEmpty

Returns whether the scheduling queue is empty.

.clear

Clears the scheduling queue

.queue

Returns:

The instance of PriorityQueue used internally as scheduling queue.

.recursive

.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

Examples