on master help sign in
Remove the recorder stuff for now
commit560d322678261243691c64e96166d8154ac73824 authorHarendra Kumar <harendra.kumar@gmail.com> dateMon 4 Sep 2017, 16:39 (9 years ago) parent28de8ff
3 files changed−90
asyncly.cabal−2 src/Asyncly/AsyncT.hs−15 src/Asyncly/Recorder.hs−73
asyncly.cabal−2
@@ -42,7 +42,6 @@ library
4242 , lifted-base >= 0.2 && < 0.3
4343 , lockfree-queue >= 0.2.3 && < 0.3
4444 , monad-control >= 1.0 && < 2
45− , monad-recorder >= 0.1 && < 0.2
4645 , mtl >= 2.2 && < 3
4746 , stm >= 2.4.3 && < 2.5
4847 , transformers >= 0.5 && < 0.6
@@ -59,7 +58,6 @@ test-suite test
5958 , base >= 4.8 && < 5
6059 , hspec >= 2.0 && < 3
6160 , containers >= 0.5 && < 0.6
62− , monad-recorder >= 0.1 && < 0.2
6361 default-language: Haskell2010
6462
6563benchmark bench
src/Asyncly/AsyncT.hs−15
@@ -66,9 +66,6 @@ import Data.Set (Set)
6666import qualified Data.Set as S
6767import Prelude hiding (take, drop)
6868
69−import Control.Monad.Trans.Recorder (MonadRecorder(..))
70−
71−
7269------------------------------------------------------------------------------
7370-- Concurrency Semantics
7471------------------------------------------------------------------------------
@@ -288,9 +285,6 @@ allThreadsDone :: MonadIO m => Context m a -> m Bool
288285allThreadsDone ctx = liftIO $ do
289286 readIORef (runningThreads ctx) >>= return . S.null
290287
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
294288{-# NOINLINE handleChildException #-}
295289handleChildException :: MonadIO m => Context m a -> SomeException -> m ()
296290handleChildException ctx e = do
@@ -548,15 +542,6 @@ instance MonadState s m => MonadState s (AsyncT m) where
548542 put x = lift (put x)
549543 state k = lift (state k)
550544
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−
560545------------------------------------------------------------------------------
561546-- Running the monad
562547------------------------------------------------------------------------------
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