control-event 1.0.0.1 → 1.1.0.0
raw patch · 2 files changed
+14/−11 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Control.Event.Relative: type EventId = (ThreadId, MVar ())
+ Control.Event.Relative: type EventId = (ThreadId, MVar Bool)
Files
- Control/Event/Relative.hs +13/−10
- control-event.cabal +1/−1
Control/Event/Relative.hs view
@@ -10,9 +10,10 @@ import Prelude hiding (catch) import Control.Concurrent import Control.Exception+import Control.Monad (when) import Control.Concurrent.MVar -type EventId = (ThreadId, MVar ())+type EventId = (ThreadId, MVar Bool) -- |'addEvent delay action' will delay -- for 'delay' microseconds then execute 'action'. An EventId@@ -24,17 +25,19 @@ return (t,m) where eventThread m = do- threadDelay delay- forkIO event- putMVar m ()+ threadDelay delay+ forkIO $ runThread m+ return ()+ runThread m = do+ b <- swapMVar m True+ when (not b) event + -- |'delEvent eid' deletes the event and returns -- 'True' if the event was _probably_ deleted*. If 'False' is returned -- then the time definately elapsed and the action was forked off.------ * There is a small possibility the delEvent occured after the forkIO--- but before the signalling MVar was filled, thus causing this uncertainty. delEvent :: EventId -> IO Bool-delEvent (t,m) =- killThread t >>- isEmptyMVar m+delEvent (t,m) = do+ killThread t+ b <- swapMVar m True+ return (not b)
control-event.cabal view
@@ -1,5 +1,5 @@ name: control-event-version: 1.0.0.1+version: 1.1.0.0 synopsis: Event scheduling system. description: Allows scheduling and canceling of IO actions to be executed at a specified future time.