All Manuals > LispWorks® User Guide and Reference Manual > 19 Multiprocessing

19.9 Timers

Use timers to run code after a specified time has passed. You can schedule a timer to run once or repeat at regular intervals, and you can unschedule it before it expires.

The timers are measured in elapsed time and the accuracy depends on various factors, including the operating system and the load on the computer.

For the details, see the reference entries for make-timer and schedule-timer.

19.9.1 Timers and multiprocessing

Timers run in unpredictable threads, therefore it is not safe to run code that interacts with the user directly. The recommended solution is something like:

 (mp:make-timer 'capi:execute-with-interface
                'capi:display-message "Time's up")


 (mp:make-timer 'capi:execute-with-interface
                'capi:display-message "Lunchtime")
 (* 4 60 60))

where interface is an existing CAPI interface on the screen.

Timers actually run in the process that is current when the scheduled time is reached. This is likely to be The Idle Process in cases where LispWorks is sleeping, but it is inherently unpredictable.

19.9.2 Input and output for timer functions

I/O streams default to the standard input and output of the process, which is initially *terminal-io* in the case of The Idle Process.

LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:21