From 6f006163ecb6359f239044e4cf62e838fc8f7927 Mon Sep 17 00:00:00 2001 From: joe Date: Sun, 5 Nov 2017 17:17:18 -0500 Subject: Trailing whitespace. --- Control/Concurrent/STM/StatusCache.hs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Control/Concurrent') diff --git a/Control/Concurrent/STM/StatusCache.hs b/Control/Concurrent/STM/StatusCache.hs index f6295aa0..d1c977ae 100644 --- a/Control/Concurrent/STM/StatusCache.hs +++ b/Control/Concurrent/STM/StatusCache.hs @@ -32,13 +32,13 @@ -- > import Control.Concurrent (forkIO, threadDelay) -- > import System.IO (hFlush, stdout) -- > import qualified Control.Concurrent.STM.StatusCache as Cache --- > +-- > -- > main = do q <- atomically $ Cache.new (== '(') (==')') -- > backlog q "(aaa(a))(bb)(cc(c)cc)" -- > fast q "(aaa(a))(bb)(cc(c)cc)" --- > +-- > -- > while pred body = pred >>= flip when (body >> while pred body) --- > +-- > -- > backlog q xs = do putStr $ "Backlogged consumer: " -- > mapM_ (atomically . Cache.push q) xs -- > while (atomically $ fmap not $ Cache.isEmpty q) $ do @@ -46,7 +46,7 @@ -- > putChar c -- > putStrLn "" -- > hFlush stdout --- > +-- > -- > fast q xs = do putStr "Fast consumer: " -- > forkIO $ forever $ do -- > c <- atomically $ Cache.pull q @@ -90,7 +90,7 @@ data StatusCache x = -- begins or ends a message. new :: (x -> Bool) -> (x -> Bool) -> STM (StatusCache x) new isStart isStop = do - feed <- newTChan >>= newTVar + feed <- newTChan >>= newTVar cache <- newTChan >>= newTVar flag <- newTVar True pushd <- newTVar 0 @@ -103,10 +103,10 @@ new isStart isStop = do , isStarter = isStart , isStopper = isStop } - + -- | Pull off a chunk from the 'StatusCache' for processing. --- +-- -- If chunks are not pulled off quickly, they may be obsoleted -- and discarded when new messages are 'push'ed. pull :: StatusCache x -> STM x @@ -127,7 +127,7 @@ pull q = do modifyTVar' (pullDepth q) (+1) when (depth==0) $ writeTVar (feedFlag q) False - when (isStopper q v) + when (isStopper q v) $ modifyTVar' (pullDepth q) (subtract 1) return v @@ -140,13 +140,13 @@ push q v = do modifyTVar' (pushDepth q) (subtract 1) when (depth==0) $ writeTVar (feedFlag q) True - when (isStarter q v) + when (isStarter q v) $ modifyTVar' (pushDepth q) (+1) chan <- if shouldCache then do when (depth==0 && isStarter q v) - $ newTChan - >>= writeTVar (cache q) + $ newTChan + >>= writeTVar (cache q) readTVar $ cache q else do readTVar $ feed q -- cgit v1.2.3