Control-Engine 0.0.2 → 0.0.3
raw patch · 2 files changed
+11/−4 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Control-Engine.cabal +1/−1
- Control/Engine.hs +10/−3
Control-Engine.cabal view
@@ -1,5 +1,5 @@ name: Control-Engine-version: 0.0.2+version: 0.0.3 license: BSD3 license-file: LICENSE author: Thomas DuBuisson <thomas.dubuisson@gmail.com>
Control/Engine.hs view
@@ -173,17 +173,24 @@ runStage _ Nothing = return Nothing runStage stage (Just a) = stage a +-- FIXME, clean up this redundant code - its ugly! stateManager :: (Eq st) => Engine job result st -> MVar st -> IO () stateManager eng ms = do- curr <- atomically $ do -- FIXME, clean up this redundant code - its ugly!+ curr@(s,ih,eh,th,oh) <- atomically $ do s <- readTVar (state eng) ih <- readTVar (tvInHook eng) eh <- readTVar (tvPreMutateHook eng) th <- readTVar (tvPostMutateHook eng) oh <- readTVar (tvOutHook eng) return (s,ih, eh, th, oh)+ swapMVar' ms s+ swapMVar' (mvInHook eng) ih+ swapMVar' (mvPreMutateHook eng) eh+ swapMVar' (mvPostMutateHook eng) th+ swapMVar' (mvOutHook eng) oh updateState curr where+ swapMVar' m v = swapMVar m v >> return () updateState (s, ih, eh, th, oh) = do new@(s', ih', eh', th', oh') <- atomically $ do s' <- readTVar (state eng)@@ -191,7 +198,7 @@ eh' <- readTVar (tvPreMutateHook eng) th' <- readTVar (tvPostMutateHook eng) oh' <- readTVar (tvOutHook eng)- when (not $ s' == s && ih' == ih && eh' == eh && th' == th && oh' == oh) retry+ when (s' == s && ih' == ih && eh' == eh && th' == th && oh' == oh) retry return (s', ih', eh', th', oh') when (s' /= s) (swapMVar ms s' >> return ()) when (ih' /= ih) (swapMVar (mvInHook eng) ih' >> return ())@@ -249,7 +256,7 @@ runHooks hooks st m = foldM apply (Just m) hooks where apply Nothing f = return Nothing- apply (Just a) f = (hkFunc f st) a+ apply (Just a) f = hkFunc f st a -- |Adds a hook that will be performed in serial on all jobs added to -- the input queue.