[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:
http://www.haskell.org/pipermail/glasgow-haskell-users/2004-January/006148.html
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
action1
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:
http://cvs.haskell.org/darcs/haskore/src/Haskore/Basic/Schedule.lhs
More information about the Haskell-Cafe
mailing list