Schedulable class | events.t[223]

An item that can be scheduled for time-based notifications. The main scheduler loop in runScheduler() operates on objects of this class.

Note that we build a list of all Schedulable instances during pre-initialization. If any Schedulable objects are dynamically created, they must be added to the list explicitly after creation in order for the event manager to schedule them for execution. The default constructor does this automatically, so subclasses can simply inherit our constructor to be added to the master list.

`class Schedulable : object`

Superclass Tree (in declaration order)

`Schedulable`
`object`

Subclass Tree

`Schedulable`
`Actor`
`UntakeableActor`
`Person`

Global Objects

`eventManager`

Summary of Properties

`allSchedulables gameClockTime nextRunTime scheduleOrder`

Summary of Methods

`calcScheduleOrder construct execute executeTurn getNextRunTime incNextRunTime`

Properties

`allSchedulables` | `events.t[308]`

A list of all of the Schedulable objects in the game. We set this up during pre-initialization; if any Schedulable instances are created dynamically, they must be explicitly added to this list after creation.

`gameClockTime` | `events.t[300]`

A class variable giving the current game clock time. This is a class variable because there's only one global game clock. The game clock starts at zero and increments in game time units; a game time unit is the arbitrary quantum of time for our event scheduling system.

`nextRunTime` | `events.t[291]`

my next running time, in game clock time

`scheduleOrder` | `events.t[273]`

Scheduling order. This determines which item goes first when multiple items are schedulable at the same time (i.e., they all have the same getNextRunTime() values). The item with the lowest number here goes first.

This should never be evaluated except immediately after a call to calcScheduleOrder.

Methods

`calcScheduleOrder ( )` | `events.t[288]`

Calculate the scheduling order, returning the order value and storing it in our property scheduleOrder. This is used to calculate and cache the value prior to sorting a list of schedulable items. We use this two-step approach (first calculate, then sort) so that we avoid repeatedly evaluating a complex calculation, if indeed there is a complex calculation to perform.

By default, we assume that the schedule order is static, so we simply leave our scheduleOrder property unchanged and return its present value.

`construct ( )` | `events.t[225]`

construction - add myself to the Schedulable list

`execute ( )` | `events.t[320]`

Execute preinitialization. Build a list of all of the schedulable objects in the game, so that we can scan this list quickly during play.

`executeTurn ( )` | `events.t[262]`

Notify this object that its scheduled run time has arrived. This should perform the scheduled task. If the scheduled task takes any game time, the object's internal next run time should be updated accordingly.

The scheduler will invoke this method of the same object repeatedly for as long as its nextRunTime remains unchanged AND this method returns true. If the object's scheduling priority changes relative to other schedulable objects, it should return nil here to tell the scheduler to recalculate scheduling priorities.

`getNextRunTime ( )` | `events.t[240]`

Get the next time (on the game clock) at which I'm eligible for execution. We won't receive any scheduling notifications until this time. If this object doesn't want any scheduling notifications, return nil.

`incNextRunTime (amt)` | `events.t[243]`

advance my next run time by the given number of clock units

TADS 3 Library Manual
Generated on 8/21/2012 from TADS version 3.1.2