Created
July 14, 2010 14:18
-
-
Save aycanirican/475462 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
-- | throw a timeout exception to the handling thread -- it'll clean up | |
-- everything | |
timerCallback :: EvLoopPtr -- ^ loop obj | |
-> EvTimerPtr -- ^ timer obj | |
-> IORef CTime -- ^ when to timeout? | |
-> MVar ThreadId -- ^ thread to kill | |
-> TimerCallback | |
timerCallback loop tmr ioref tmv _ _ _ = do | |
debug "Backend.timerCallback: entered" | |
now <- getCurrentDateTime | |
whenToDie <- readIORef ioref | |
if whenToDie < now | |
then do | |
debug "Backend.timerCallback: killing thread" | |
tid <- readMVar tmv | |
throwTo tid TimeoutException | |
else do -- re-arm the timer | |
-- fixme: should set repeat here, have to wait for an hlibev patch to | |
-- do it | |
let newtval = fromRational . toRational $ (whenToDie - now) | |
evTimerSetRepeat tmr newtval | |
evTimerAgain loop tmr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment