Workflow 0.8.0.2 → 0.8.0.3
raw patch · 2 files changed
+27/−20 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Control/Workflow.hs +23/−19
- Workflow.cabal +4/−1
Control/Workflow.hs view
@@ -197,7 +197,6 @@ type WorkflowList m a b= M.Map String (a -> Workflow m b) - instance Monad m => Monad (WF s m) where return x = WF (\s -> return (s, x)) WF g >>= f = WF (\s -> do@@ -1083,7 +1082,7 @@ -- | Wait until a TCache object (with a certaing key) meet a certain condition (useful to check external actions )--- NOTE if anoter process delete the object from te cache, then waitForData will no longuer work+-- NOTE if anoter process delete the object from te cache, then waitForData will no longer work -- inside the wokflow, it can be used by lifting it : -- do -- x <- step $ ..@@ -1111,7 +1110,7 @@ False -> retry True -> return x --- | Observe the workflow log untiil a condition is met.+-- | Observe the workflow log until a condition is met. waitFor :: ( Indexable a, Serialize a, Serialize b, Typeable a , Indexable b, Typeable b)@@ -1126,7 +1125,7 @@ , Indexable b, Typeable b) => (b -> Bool) -- ^ The condition that the retrieved object must meet -> String -- ^ The workflow name- -> a -- ^ The INITIAL value used in the workflow to start it+ -> a -- ^ The INITIAL value used in the workflow -> STM b -- ^ The first event that meet the condition waitForSTM filter wfname x= do let name= keyWF wfname x@@ -1141,17 +1140,17 @@ Left _ -> retry -- `debug` "waithFor retry Nothing" Right x -> case filter x of- False -> retry -- `debug` "waitFor false filter retry"- True -> return x -- `debug` "waitfor return"+ False -> retry -- `debug` "waitFor false filter retry"+ True -> return x -- `debug` "waitfor return" --{-# DEPRECATED waitUntilSTM, getTimeoutFlag "use withTimeout instead" #-} -- | Start the timeout and return the flag to be monitored by 'waitUntilSTM'--- This timeout is persistent. This means that the time start to count from the first call to getTimeoutFlag on--- no matter if the workflow is restarted. The time that the worlkflow has been stopped count also.--- the wait time can exceed the time between failures.+-- This timeout is persistent. This means that the counter is initialized in the first call to getTimeoutFlag+-- no matter if the workflow is restarted. The time during which the worlkflow has been stopped count also.+-- Thus, the wait time can exceed the time between failures. -- when timeout is 0 means no timeout. getTimeoutFlag :: MonadIO m@@ -1171,6 +1170,9 @@ forkIO $ do waitUntil t ; atomically $ writeTVar tv True return (s, tv) +++ getTimeSeconds :: IO Integer getTimeSeconds= do TOD n _ <- getClockTime@@ -1194,10 +1196,11 @@ --longWait time wf= -- WF $ \s -> do -- flag <- getTimeoutFlag time--- forkIO $ atomically $ do--- b <- readTVar tv+-- forkIO $ do+-- atomically $ do+-- b <- readTVar flag -- if b == False then retry else return ()--- start (wfName s) wf+-- start (wfName s) wf "" -- myThreadId >>= killThread @@ -1210,7 +1213,7 @@ -- See `waitUntilSTM` waitUntil:: Integer -> IO()-waitUntil t= getTimeSeconds >>= \tnow -> wait (t-tnow)+waitUntil t= getTimeSeconds >>= \tnow -> wait ((t-tnow)*1000000) wait :: Integer -> IO()@@ -1218,14 +1221,14 @@ let delay | delta < 0= 0 | delta > (fromIntegral maxInt) = maxInt | otherwise = fromIntegral $ delta- threadDelay $ delay * 1000000+ threadDelay $ delay if delta <= 0 then return () else wait $ delta - (fromIntegral delay ) -- | Return either the result of the STM conputation or Nothing in case of timeout--- This timeout is persistent. This means that the time start to count from the first call to getTimeoutFlag on--- no matter if the workflow is restarted. The time that the worlkflow has been stopped count also.+-- This timeout is persistent. This means that the counter is initialized in the first call to getTimeoutFlag+-- no matter if the workflow is restarted. The time during which the worlkflow has been stopped count also. -- Thus, the wait time can exceed the time between failures.--- when timeout is 0 means no timeout.+-- when timeout is 0 it means no timeout. withTimeout :: ( MonadIO m, Typeable a, Serialize a)=> Integer -> STM a -> Workflow m (Maybe a) withTimeout time f = do flag <- getTimeoutFlag time @@ -1236,9 +1239,10 @@ -- | Executes a computation understanding that it is inside the -- workflow identified by 'id'. If 'f' finish after 'time'--- it genetates a 'Timeout' exception which must result in the end of the workflow.+-- it genetates a 'Timeout' exception which may result in the end of the workflow if the+-- programmer does not catch it. -- If the workflow is restarted after 'time2' has elapsed, the workflow--- will restart from the beginning. If not, it will restart at the last checkpoint.+-- will restart from the beginning. If not, it will restart after the last logged step. -- -- Usually @time2> time@ --
Workflow.cabal view
@@ -1,5 +1,5 @@ name: Workflow-version: 0.8.0.2+version: 0.8.0.3 cabal-version: >= 1.6 build-type: Simple license: BSD3@@ -20,6 +20,9 @@ and a general configuarion utility. . See "Control.Workflow" for details+ .+ In this release:+ * timeout miscalculated in time-related primitives fixed category: Control, Workflow