10.10. File too/Timer

class too.Timer

Instances of the Timer class provide, in conjunction with the RunLoop, event scheduling functionality. Timer objects can fire once or repeatedly.

Because the trigger time of a Timer can change, in case of repeated firing, a Timer is not a Date: a Timer represents a moment in time like a Date, but a Date is assumed to be constant.

inherits

State supers: HeapElement

methods


instance (id)
  withInterval double secs
    invocation Invocation invocation
      repeats: boolean repeats_p = NO
pre
  secs > 0.0 || !repeats_p && !secs;

Return a newly allocated Timer instance to fire secs from now, with the Invocation invocation. Iff repeats_p, the timer will repeat every secs.

instance too.Timer

variables

public double fire_time;

The next (relative) moment in time we will fire.

public double period;

The repetition period. This is 0.0 for a single-shot timer.

Invocation invocation;

The invocation to fire when we do.

methods


id (self)
  initWithFireTime double d
        invocation Invocation i
           period: double p = 0.0
pre
  p >= 0.0;

Designated initializer. If the time d lies in the past, the timer will fire as soon as possible.


void
  fire;

Fire the timer and invoke the invocation. If the timer is repeating, and the invocation did not throw any conditions, then the timer will be re-added to the current RunLoop. Unfortunately, this will fail silently.


OutputStream (s)
  writeFields OutputStream s;

Undocumented.


void
  cancel
pre
  [self scheduled];

Cancel this timer with the current RunLoop. It must be scheduled with that RunLoop.


void
  schedule
pre
  ![self scheduled];

Schedule this timer with the current RunLoop. The timer must not already be scheduled.


boolean
  scheduled;

Return whether this timer is currently scheduled.


int
  compare id other;

Return a comparison of the firing times of the two timers.