packages feed

data-ivar 0.11 → 0.20

raw patch · 2 files changed

+22/−8 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.IVar: combo :: Reader a -> IO (Either a (IO a))

Files

Data/IVar.hs view
@@ -37,7 +37,7 @@  module Data.IVar      ( IVar, new, write, read-    , Reader, nonblocking, blocking+    , Reader, nonblocking, blocking, combo     ) where @@ -176,10 +176,24 @@     r <- runReader reader     case r of         Left x -> return x-        Right log -> do-            blocker <- newEmptyMVar-            cleanup <- forM log $ \(LogEntry var action) -> do-                ident <- addAction var (\v -> tryPutMVar blocker (action v) >> return ())-                return $ deleteAction var ident-            blocking =<< takeMVar blocker+        Right log -> primBlocking log +primBlocking :: [LogEntry (Reader a)] -> IO a+primBlocking log = do+    blocker <- newEmptyMVar+    cleanup <- forM log $ \(LogEntry var action) -> do+        ident <- addAction var (\v -> tryPutMVar blocker (action v) >> return ())+        return $ deleteAction var ident+    blocking =<< takeMVar blocker++-- | Combination nonblocking and blocking read.  @combo r@ +-- Returns @Left x@ if the value is available now, otherwise +-- returns @Right (blocking r)@.  This is more efficient than+-- using nonblocking and blocking in sequence (it only evaluates+-- the Reader once).+combo :: Reader a -> IO (Either a (IO a))+combo reader = do+    r <- runReader reader+    case r of+        Left x -> return (Left x)+        Right log -> return . Right $ primBlocking log
data-ivar.cabal view
@@ -3,7 +3,7 @@     Write-once variables, with the ability to block     on the first of a set of variables to become      available.-Version: 0.11+Version: 0.20 Stability: experimental Synopsis: Write-once variables with concurrency support License: BSD3