Tickers are for when you want to do something repeatedly at regular intervals. Here’s an example of a ticker that ticks periodically until we stop it.
When we run this program the ticker should tick 3 times before we stop it.
In this Lisp version, we’re using the bordeaux-threads library for multi-threading and the local-time library for timestamp handling. The concept of channels is replaced with condition variables and locks, which are common synchronization primitives in Lisp.
The make-thread function creates a new thread that runs the ticker. The ticker uses condition-wait with a timeout to simulate the periodic ticking. The main thread sleeps for 1.6 seconds before signaling the ticker to stop.
Note that the exact timing and number of ticks may vary slightly due to differences in how threading and scheduling work in different Lisp implementations and operating systems.