Created
April 13, 2010 14:14
-
-
Save tibbe/364661 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
-- | Register a timeout in the given number of milliseconds. | |
registerTimeout :: EventManager -> Int -> TimeoutCallback -> IO TimeoutKey | |
registerTimeout mgr ms cb = do | |
key <- newUnique (emUniqueSource mgr) | |
now <- getCurrentTime | |
let expTime = fromIntegral ms / 1000.0 + now | |
_ <- atomicModifyIORef (emTimeouts mgr) $ \q -> | |
let q' = Q.insert key expTime cb q in (q', q') | |
wakeManager mgr | |
return $! TK key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment