Skip to content

Instantly share code, notes, and snippets.

@tibbe
Created April 13, 2010 14:14
Show Gist options
  • Save tibbe/364661 to your computer and use it in GitHub Desktop.
Save tibbe/364661 to your computer and use it in GitHub Desktop.
-- | 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