on master help sign in
Remove the recorder stuff for now
560d322Harendra Kumar
asyncly.cabal−2
@@ -42,7 +42,6 @@ library
42 , lifted-base >= 0.2 && < 0.3
42 , lifted-base >= 0.2 && < 0.3
43 , lockfree-queue >= 0.2.3 && < 0.3
43 , lockfree-queue >= 0.2.3 && < 0.3
44 , monad-control >= 1.0 && < 2
44 , monad-control >= 1.0 && < 2
45− , monad-recorder >= 0.1 && < 0.2
46 , mtl >= 2.2 && < 3
45 , mtl >= 2.2 && < 3
47 , stm >= 2.4.3 && < 2.5
46 , stm >= 2.4.3 && < 2.5
48 , transformers >= 0.5 && < 0.6
47 , transformers >= 0.5 && < 0.6
@@ -59,7 +58,6 @@ test-suite test
59 , base >= 4.8 && < 5
58 , base >= 4.8 && < 5
60 , hspec >= 2.0 && < 3
59 , hspec >= 2.0 && < 3
61 , containers >= 0.5 && < 0.6
60 , containers >= 0.5 && < 0.6
62− , monad-recorder >= 0.1 && < 0.2
63 default-language: Haskell2010
61 default-language: Haskell2010
64
62
65benchmark bench
63benchmark bench
src/Asyncly/AsyncT.hs−15
@@ -66,9 +66,6 @@ import Data.Set (Set)
66import qualified Data.Set as S
66import qualified Data.Set as S
67import Prelude hiding (take, drop)
67import Prelude hiding (take, drop)
68
68
69−import Control.Monad.Trans.Recorder (MonadRecorder(..))
70−
71−
72------------------------------------------------------------------------------
69------------------------------------------------------------------------------
73-- Concurrency Semantics
70-- Concurrency Semantics
74------------------------------------------------------------------------------
71------------------------------------------------------------------------------
@@ -288,9 +285,6 @@ allThreadsDone :: MonadIO m => Context m a -> m Bool
288allThreadsDone ctx = liftIO $ do
285allThreadsDone ctx = liftIO $ do
289 readIORef (runningThreads ctx) >>= return . S.null
286 readIORef (runningThreads ctx) >>= return . S.null
290
287
291−-- If an exception occurs we push it to the channel so that it can handled by
292−-- the parent. 'Paused' exceptions are to be collected at the top level.
293−-- XXX Paused exceptions should only bubble up to the runRecorder computation
294{-# NOINLINE handleChildException #-}
288{-# NOINLINE handleChildException #-}
295handleChildException :: MonadIO m => Context m a -> SomeException -> m ()
289handleChildException :: MonadIO m => Context m a -> SomeException -> m ()
296handleChildException ctx e = do
290handleChildException ctx e = do
@@ -548,15 +542,6 @@ instance MonadState s m => MonadState s (AsyncT m) where
548 put x = lift (put x)
542 put x = lift (put x)
549 state k = lift (state k)
543 state k = lift (state k)
550
544
551−------------------------------------------------------------------------------
552−-- MonadRecorder
553−------------------------------------------------------------------------------
554−
555−instance MonadRecorder m => MonadRecorder (AsyncT m) where
556− getJournal = lift getJournal
557− putJournal = lift . putJournal
558− play = lift . play
559−
560------------------------------------------------------------------------------
545------------------------------------------------------------------------------
561-- Running the monad
546-- Running the monad
562------------------------------------------------------------------------------
547------------------------------------------------------------------------------
src/Asyncly/Recorder.hsdeleted−73
@@ -1,73 +0,0 @@
1−{-# LANGUAGE FlexibleContexts #-}
2−{-# LANGUAGE FlexibleInstances #-}
3−{-# LANGUAGE StandaloneDeriving #-}
4−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5−
6−-- |
7−-- Module : Asyncly.Recorder
8−-- Copyright : (c) 2017 Harendra Kumar
9−--
10−-- License : BSD3
11−-- Maintainer : harendra.kumar@gmail.com
12−-- Stability : experimental
13−-- Portability : GHC
14−--
15−module Asyncly.Recorder
16− ( runAsynclyRecorded
17−-- , toListRecorded
18− , playRecordings
19− )
20−where
21−
22−import Control.Applicative (Alternative (..))
23−import Control.Monad (liftM)
24−import Control.Monad.Catch (MonadThrow)
25−import Control.Monad.IO.Class (MonadIO (..))
26−import Control.Monad.Trans.Class (MonadTrans (lift))
27−import Control.Monad.State (StateT(..), runStateT)
28−import Data.Monoid ((<>))
29−import Data.IORef (IORef, newIORef, readIORef)
30−
31−import Control.Monad.Trans.Recorder (MonadRecorder(..), RecorderT,
32− Recording, blank, runRecorderT)
33−import Asyncly.AsyncT
34−
35−------------------------------------------------------------------------------
36−-- Running the monad with recording
37−------------------------------------------------------------------------------
38−
39−-- | Compose a computation using previously captured logs
40−playRecording :: (MonadAsync m, MonadRecorder m)
41− => AsyncT m a -> Recording -> AsyncT m a
42−playRecording m recording = play recording >> m
43−
44−-- | Resume an 'AsyncT' computation using previously recorded logs. The
45−-- recording consists of a list of journals one for each thread in the
46−-- computation.
47−playRecordings :: (MonadAsync m, MonadRecorder m)
48− => AsyncT m a -> [Recording] -> AsyncT m a
49−playRecordings m logs = each logs >>= playRecording m
50−
51−{-
52−-- | Run an 'AsyncT' computation with recording enabled, wait for it to finish
53−-- returning results for completed threads and recordings for paused threads.
54−toListRecorded :: (MonadAsync m, MonadCatch m)
55− => AsyncT m a -> m ([a], [Recording])
56−toListRecorded m = do
57− resultsRef <- liftIO $ newIORef []
58− lref <- liftIO $ newIORef []
59− waitAsync (gatherResult resultsRef) (Just lref) m
60− res <- liftIO $ readIORef resultsRef
61− logs <- liftIO $ readIORef lref
62− return (res, logs)
63− -}
64−
65−-- | Run an 'AsyncT' computation with recording enabled, wait for it to finish
66−-- and discard the results and return the recordings for paused threads, if
67−-- any.
68−runAsynclyRecorded :: MonadAsync m => AsyncT (RecorderT m) a -> m [Recording]
69−runAsynclyRecorded m = do
70− lref <- liftIO $ newIORef []
71− runRecorderT blank (runAsynclyLogged (Just lref) m)
72− logs <- liftIO $ readIORef lref
73− return logs