ToC DocOverview CGDoc RelNotes FAQ Index PermutedIndex
Allegro CL version 11.0

About the Common Graphics timer facility

A timer can be used to cause an arbitrary piece of application code to be asynchronously invoked after a specified amount of time has elapsed. A timer can then be stopped in order to run its code a single time only, or it can be allowed to continue running in order to run its code an indefinite number of times at a regular time interval.

Common Graphics has a timer class, which can be instantiated to create a timer object. A single timer can be started and stopped a number of times, using various time intervals, to time a number of different activities. If multiple activities need to be timed simultaneously, then multiple timers can be created and run alongside each other. It is also convenient to create a separate timer for each piece of code that is to be invoked by timers, even when they do not need to run simultaneously.

A timer is an instance of the timer class, which has the following properties. All of these except for id may be set by an application. See the page for the timer class or for the individual properties for more detailed information.

Functions that apply to all timers

Functions apply to particular built-in timers

A trivial timer example

;; Define an on-timer event handler 
(defun my-on-timer (timer)
   ;; Show a status bar message each time the timer fires.
   (lisp-message "Timer event ~a for ~s"
     (timer-count timer)(name timer)))

;; Create a timer that uses the above on-timer event-handler.
(setq tim (make-instance 'timer :on-timer 'my-on-timer))

(active tim) ==> nil        ;; the new timer is not active yet

;; Start the timer, telling it to fire every half second
(start-timer tim :interval 500)

(active tim) ==> t          ;; now it's active

(stop-timer tim)            ;; stop it for a while

(setf (active tim) t)       ;; this is another way to start it back up

(setf (interval tim) 800)   ;; slow it down even while it's running

(setf (active tim) nil)     ;; another way to stop it

Copyright (c) Franz Inc. Lafayette, CA., USA. All rights reserved.

ToC DocOverview CGDoc RelNotes FAQ Index PermutedIndex
Allegro CL version 11.0