ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.0
Unrevised from 9.0 to 10.0.
9.0 version

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

find-timer
start-timer
stop-timer
timer

Functions apply to particular built-in timers

A trivial timer example

On the GTK platform you might need to adjust the value of *cg-timer-resolution*.

;; 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) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 9.0 page.
Created 2015.5.21.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.0
Unrevised from 9.0 to 10.0.
9.0 version