Next: , Previous: , Up: The language   [Contents][Index]


5.36 Asynchronous Timers

The rep.io.timers module (see Modules) allows a Lisp program to create multiple asynchronous timers, primed to call a specified function after some time.

A timer is not a thread. It works when the event loop is being used, i.e. at least one recursive-edit is currently in progress. A timer is called between cycles of event loop.

Function: make-timer function #!optional seconds milliseconds

Create and return a new timer object. It will be set to call the Lisp function function after seconds seconds plus milliseconds milliseconds. function will be called with a single argument, the timer object that has just fired.

If both seconds and milliseconds are undefined, or zero, the timer will be created but won’t call function.

After the time interval has passed, and function has been called, the timer will not be restarted. Use the set-timer function to reset it.

Function: delete-timer timer

Prevent the timer object timer from calling the Lisp function associated with it. Use the set-timer function to reset it.

Function: set-timer timer #!optional seconds milliseconds

Reset the timer object timer. If either/both of seconds and milliseconds are defined the interval of the timer will be set to the specified time period. If neither are defined then the current interval of the timer is preserved.