Skip to content

Instantly share code, notes, and snippets.

@NathanHowell
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NathanHowell/529390f9b6da1c9cbc89 to your computer and use it in GitHub Desktop.
Save NathanHowell/529390f9b6da1c9cbc89 to your computer and use it in GitHub Desktop.
{-# 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