This is the mail archive of the
mailing list for the Guile project.
Re: Using async's in Guile.
"Bradley M. Kuhn" <email@example.com> writes:
> Hmmm...so, what is the best way now to handle a case where I need a clock to
> invoke some function after a specified amount of time.
> Right now, I am using a clock implementation that uses SIGALRM underneath.
> I would like something a bit more versatile.
> Any suggestions? Attached is my current implementation of the clock.
Is the exactness of time important? One suggestion is to spawn a
thread for each clock:
(define (make-barizer foo ms)
(let ((us (* ms 1000)))
(let loop ()
Otherwise, it doesn't seem like a bad idea to use SIGALRM. If you
want to be able to use several clocks, you can always write a layer
in-between which handles this. (You use code which can support
multiple handlers. This code, in turn, is based on SIGALRM.)
If 1 s is too small resolution, then you could use some other
interrupt, like the virtual timer. (I'm not sure that Guile supports
that now, but it is easy to copy the code for the `alarm' primitive
and modify it into a virtual timer primitive. If you do this, I can
include it in the distribution.)