[Haskell-cafe] accurately scheduling events

Henning Thielemann lemming at henning-thielemann.de
Mon Apr 10 08:40:20 EDT 2006

I try to schedule musical events and this shall happen quite accurately. I 
found 'usleep' which is limited to Posix and I cannot interrupt with 
Ctrl-C if IO actions are scheduled using this function. Then I found 
'threadDelay' which can be interrupted, but it is stated that its 
resolution is 1/50 seconds, which is too coarse. Additionally I found that 
it liberally rounds the waiting time up to the next multiple of 1/50 
second. Even 'threadDelay 0' waits some time. This might be due to the 
fact that threadDelay was not intended for such applications, but it shall 
wait at least the time specified:

My question: Is there some more accurate time scheduling available? Maybe 
not only a more accurate 'wait' function but a function which processes a 
list of events and starts the actions at the appropriate time points. When 
I write

do action0
    threadDelay t

then action1 is not started duration t after action0 is started, but time 
t after action0 is finished. This should be avoided by a sophisticated 
scheduling function.

This is how I currently employ threadDelay:

More information about the Haskell-Cafe mailing list