HaskellWiki

Haskell | Wiki community | Recent changes
Random page | Special pages

 

Not logged in
Log in | Help

Note: new account creation has been disabled as an anti-spam measure.

Control-event

Categories: Libraries | Packages

Contents

1 Introduction

The control-event package provides the capability to schedule and cancel IO () actions for arbitrary absolute times. Source code is available from hackage[1] and the repository[2].

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

4 See Also

Retrieved from "http://haskell.org/haskellwiki/Control-event"

This page has been accessed 1,081 times. This page was last modified 19:41, 14 June 2008. Recent content is available under a simple permissive license.