packages feed

bounded-tchan 0.2.2 → 0.2.3

raw patch · 2 files changed

+17/−6 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Control/Concurrent/STM/BTChan.hs view
@@ -16,7 +16,6 @@  import Control.Concurrent.STM import Control.Monad (when, liftM)-import Control.Applicative  -- |A 'BTChan' is a bounded 'TChan' - a FIFO channel using 'TChan' and -- a transactional variable to limit the number of elements on the channel.@@ -30,11 +29,19 @@ -- |An IO version of 'newBTChanIO'.  This should be useful with unsafePerformIO -- in the same manner as 'newTVarIO' and 'newTChanIO' are used. newBTChanIO :: Int -> IO (BTChan a)-newBTChanIO m = BTChan m <$> newTChanIO <*> newTVarIO 0 <*> newTVarIO 0+newBTChanIO m = do+    c <- newTChanIO+    rs <- newTVarIO 0+    ws <- newTVarIO 0+    return $ BTChan m c rs ws  -- |@newBTChan m@ make a new bounded TChan of max size @m@. newBTChan :: Int -> STM (BTChan a)-newBTChan m = BTChan m <$> newTChan <*> newTVar 0 <*> newTVar 0+newBTChan m = do+    c <- newTChan+    rs <- newTVar 0+    ws <- newTVar 0+    return $ BTChan m c rs ws  -- |Writes the value to the 'BTChan' or blocks if the channel is full. writeBTChan :: BTChan a -> a -> STM ()@@ -110,7 +117,10 @@  -- |Get the current number of elements in the 'BTChan'. sizeOfBTChan :: BTChan a -> STM Int-sizeOfBTChan (BTChan _ _ rdTV wrTV) = (+) <$> readTVar wrTV <*> readTVar rdTV+sizeOfBTChan (BTChan _ _ rdTV wrTV) = do+    w <- readTVar wrTV+    r <- readTVar rdTV+    return $ w + r  -- |@let c2 = setMaxOfBTChan c1 mx@ Using the same underlying 'TChan', -- set a new maximum number of messages, @mx@.  If the current size
bounded-tchan.cabal view
@@ -1,7 +1,8 @@ Name:                bounded-tchan-Version:             0.2.2+Version:             0.2.3 Synopsis:            Bounded Transactional channels (queues)-Description:         Bounded TChan's, or BTChan's, are a transactional queue with a limit to the number of elements (further calls to @writeBTChan@ or @unGetBTChan@ call STM retry).+Description:         Bounded TChan's, or BTChan's, are a transactional queue with a limit to the number of elements (further calls to @writeBTChan@ or @unGetBTChan@ call STM retry).  Users are strongly encouraged to consider using the more complete 'stm-chans' packages, which includes a bounded TChan designed on this package.+  License:             BSD3 License-file:        LICENSE