packages feed

mstate 0.2.3 → 0.2.4

raw patch · 2 files changed

+17/−1 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Control.Concurrent.MState: waitM :: MonadPeelIO m => ThreadId -> MState t m ()

Files

mstate.cabal view
@@ -8,12 +8,16 @@ Author:         Nils Schweinsberg Maintainer:     <mail@n-sch.de> -Version:        0.2.3+Version:        0.2.4 Category:       Concurrency, Monads License:        BSD3 License-File:   LICENSE Cabal-Version:  >= 1.6 Build-Type:     Simple++source-repository head+    type: git+    location: https://github.com/mcmaniac/mstate.git  Library     GHC-Options:        -Wall
src/Control/Concurrent/MState.hs view
@@ -32,6 +32,7 @@     , forkM     , forkM_     , killMState+    , waitM        -- * Example       -- $example@@ -197,6 +198,17 @@     _ <- liftIO . forkIO $       mapM_ (killThread . fst) tms     return ()++-- | Wait for a thread to finish+waitM :: MonadPeelIO m => ThreadId -> MState t m ()+waitM tid = MState $ \(_,c) -> do+    mw <- liftIO . atomically $ do+        lookup tid `fmap` readTVar c+    maybe (return ()) wait' mw+  where+    wait' w = liftIO . atomically $ do+        () <- takeTMVar w+        putTMVar w () -- clean up again for "waitForTermination"  -------------------------------------------------------------------------------- -- Monad instances