Timers
Posted: Sat Dec 27, 2008 7:41 am
K, so i would like a timer which interrupts the lisp code and runs a specified code every x seconds. I've tried win32 standard timers, they don't work because they schedule based on how busy the program (cpu) is, and multimedia timers just crash lispworks (haven't tried any other platforms).
So, i started thinking that what i needed was a c timer program which would run in another thread, and call the lisp function whenever. But then I started thinking of all the thread issues involved, whether the lisp code called by the timer would be thread safe, etc.
But then again, i thought that there are already gui programs out there that do something similar. Cells-gtk allows interrupts, so there must be some way to get around these thread safety issues, even in a non-multitasking lisp.
So I guess my question is, are callbacks thread-safe when the function is called in the middle of a running lisp program??
Edit: On an afterthought, I might know why gui programs work. Most of the program is event based, meaning the code is run only when a button is clicked, a menu clicked, etc. So, it would be thread safe because only one event is called at one time. If one event code takes an excessively long time to execute, then maybe it would be impossible for the user to click another button, etc. until that code is completed, just like the win32 timers. Any thoughts?
So, i started thinking that what i needed was a c timer program which would run in another thread, and call the lisp function whenever. But then I started thinking of all the thread issues involved, whether the lisp code called by the timer would be thread safe, etc.
But then again, i thought that there are already gui programs out there that do something similar. Cells-gtk allows interrupts, so there must be some way to get around these thread safety issues, even in a non-multitasking lisp.
So I guess my question is, are callbacks thread-safe when the function is called in the middle of a running lisp program??
Edit: On an afterthought, I might know why gui programs work. Most of the program is event based, meaning the code is run only when a button is clicked, a menu clicked, etc. So, it would be thread safe because only one event is called at one time. If one event code takes an excessively long time to execute, then maybe it would be impossible for the user to click another button, etc. until that code is completed, just like the win32 timers. Any thoughts?