Personal tools

Control-event

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
m
m
Line 29: Line 29:
 
* While no work is planned, if someone were looking for a quick project then they could move this package over to the 'time' packages and eliminate the 'old-time' dependency.
 
* While no work is planned, if someone were looking for a quick project then they could move this package over to the 'time' packages and eliminate the 'old-time' dependency.
   
== Other Sites ==
+
== See Also ==
You can also read the poorly written blog entries [http://sequence.complete.org/node/375][http://sequence.complete.org/node/376].
+
* poorly written blog entries [http://sequence.complete.org/node/375][http://sequence.complete.org/node/376].
  +
* The Repository [http://code.haskell.org/~tommd/control-event/]

Revision as of 23:48, 12 June 2008

Contents

1 Introduction

The control-event package[1] provides the capability to schedule and cancel IO () actions for arbitrary absolute times.

A shim module that provides identical API as control-timeout (relative expiration times) is available, though it is also much less efficient then either control-timeout or control-event with absolute times.

2 Example Code

Code generally looks like this:

import Control.Monad
import Control.Event
 
main = do
    evtSys <- initEventSystem
    ...
    doStuff action delay race evtSys
 
doStuff action delay race eS = 
    (TOD sec ps) <- getClockTime
    eid <- addEvent eS (TOD (sec + delay) ps) action
    res <- race
    when res (cancelEvent eS eid)
    runUserOperation a

The test code can serve as a decent example as well.

3 Potential Future Changes

  • While no work is planned, if someone were looking for a quick project then they could move this package over to the 'time' packages and eliminate the 'old-time' dependency.

4 See Also

  • poorly written blog entries [2][3].
  • The Repository [4]