Last active
August 29, 2015 14:05
-
-
Save NathanHowell/529390f9b6da1c9cbc89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RankNTypes #-} | |
import qualified GHC.Event | |
data TimerManager2 = TimerManager2 | |
{ registerTimeout :: Int -> GHC.Event.TimeoutCallback -> IO GHC.Event.TimeoutKey | |
, updateTimeout :: GHC.Event.TimeoutKey -> Int -> IO () | |
, unregisterTimeout :: GHC.Event.TimeoutKey -> IO () | |
} | |
newTimeoutManager2 :: IO TimerManager2 | |
newTimeoutManager2 = do | |
tm <- GHC.Event.getSystemTimerManager | |
return $! TimerManager2 (GHC.Event.registerTimeout tm) (GHC.Event.updateTimeout tm) (GHC.Event.unregisterTimeout tm) | |
test :: IO () | |
test = do | |
tm2 <- newTimeoutManager2 | |
timeoutKey <- registerTimeout tm2 1000 (error "timeout callback") | |
unregisterTimeout tm2 timeoutKey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment