stm-chans 1.2.0.3 → 1.3.0
raw patch · 3 files changed
+75/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Control.Concurrent.STM.TMVar.Compat: data TMVar a :: * -> *
+ Control.Concurrent.STM.TMVar.Compat: isEmptyTMVar :: TMVar a -> STM Bool
+ Control.Concurrent.STM.TMVar.Compat: newEmptyTMVar :: STM (TMVar a)
+ Control.Concurrent.STM.TMVar.Compat: newEmptyTMVarIO :: IO (TMVar a)
+ Control.Concurrent.STM.TMVar.Compat: newTMVar :: a -> STM (TMVar a)
+ Control.Concurrent.STM.TMVar.Compat: newTMVarIO :: a -> IO (TMVar a)
+ Control.Concurrent.STM.TMVar.Compat: putTMVar :: TMVar a -> a -> STM ()
+ Control.Concurrent.STM.TMVar.Compat: readTMVar :: TMVar a -> STM a
+ Control.Concurrent.STM.TMVar.Compat: swapTMVar :: TMVar a -> a -> STM a
+ Control.Concurrent.STM.TMVar.Compat: takeTMVar :: TMVar a -> STM a
+ Control.Concurrent.STM.TMVar.Compat: tryPutTMVar :: TMVar a -> a -> STM Bool
+ Control.Concurrent.STM.TMVar.Compat: tryReadTMVar :: TMVar a -> STM (Maybe a)
+ Control.Concurrent.STM.TMVar.Compat: tryTakeTMVar :: TMVar a -> STM (Maybe a)
Files
- VERSION +2/−0
- src/Control/Concurrent/STM/TMVar/Compat.hs +69/−0
- stm-chans.cabal +4/−3
VERSION view
@@ -1,3 +1,5 @@+1.3.0 (2012-02-25):+ - Added Control.Concurrent.STM.TMVar.Compat 1.2.0.3 (2012-02-12): - Change stability from experimental to provisional. 1.2.0.2 (2012-02-12):
+ src/Control/Concurrent/STM/TMVar/Compat.hs view
@@ -0,0 +1,69 @@+{-# OPTIONS_GHC -Wall -fwarn-tabs #-}+{-# LANGUAGE CPP #-}+----------------------------------------------------------------+-- 2012.02.25+-- |+-- Module : Control.Concurrent.STM.TMVar.Compat+-- Copyright : Copyright (c) 2011--2012 wren ng thornton+-- License : BSD+-- Maintainer : wren@community.haskell.org+-- Stability : provisional+-- Portability : non-portable (STM, CPP)+--+-- Compatibility layer for older versions of the @stm@ library.+-- Namely, we define 'tryReadTMVar' which @stm-X.X.X@ lacks. This+-- module uses Cabal-style CPP macros in order to use the package+-- versions when available. This isn't actually used by the @stm-chans@+-- package, but we provide it anyways since we provide compatibility+-- layers for @TVar@ and @TChan@.+--+-- /Since: 1.3.0/+----------------------------------------------------------------+module Control.Concurrent.STM.TMVar.Compat+ (+ -- * The TMVar type+ TMVar()+ -- ** Creating TMVars+ , newTMVar -- :: a -> STM (TMVar a)+ , newTMVarIO -- :: a -> IO (TMVar a)+ , newEmptyTMVar -- :: STM (TMVar a)+ , newEmptyTMVarIO -- :: IO (TMVar a)+ -- ** Reading from TMVars+ , readTMVar -- :: TMVar a -> STM a+ , tryReadTMVar -- :: TMVar a -> STM (Maybe a)+ , takeTMVar -- :: TMVar a -> STM a+ , tryTakeTMVar -- :: TMVar a -> STM (Maybe a)+ -- ** Writing to TMVars+ , putTMVar -- :: TMVar a -> a -> STM ()+ , tryPutTMVar -- :: TMVar a -> a -> STM Bool+ , swapTMVar -- :: TMVar a -> a -> STM a+ -- TODO: make another patch for trySwapTMVar?+ -- ** Other capabilities+ , isEmptyTMVar -- :: TMVar a -> STM Bool+ ) where++import Control.Concurrent.STM.TMVar++-- BUG: What version will these really be added?+-- <http://hackage.haskell.org/trac/ghc/ticket/5104>+-- <http://www.haskell.org/pipermail/cvs-libraries/2011-April/012914.html>+#if ! (MIN_VERSION_stm(9,0,0))+import Control.Concurrent.STM (STM)+----------------------------------------------------------------++-- | A version of 'readTMVar' which does not retry. Instead it returns @Nothing@ if no value is available.+tryReadTMVar :: TMVar a -> STM (Maybe a)+tryReadTMVar var = do+ m <- tryTakeTMVar var+ case m of+ Nothing -> return Nothing+ Just x -> putTMVar var x >> return (Just x)+{- -- The optimized implementation in the patch to @stm@+tryReadTMVar (TMVar t) = readTVar t+{-# INLINE tryReadTMVar #-}+-}++#endif++----------------------------------------------------------------+----------------------------------------------------------- fin.
stm-chans.cabal view
@@ -1,5 +1,5 @@ ------------------------------------------------------------------- wren ng thornton <wren@community.haskell.org> ~ 2012.02.12+-- wren ng thornton <wren@community.haskell.org> ~ 2012.02.25 ---------------------------------------------------------------- -- By and large Cabal >=1.2 is fine; but >= 1.6 gives tested-with:@@ -9,7 +9,7 @@ Build-Type: Custom Name: stm-chans-Version: 1.2.0.3+Version: 1.3.0 Stability: provisional Homepage: http://code.haskell.org/~wren/ Author: wren ng thornton, Thomas DuBuisson@@ -36,7 +36,7 @@ -- -- N.B., stm >= 2.1.2 is required for fast readTVarIO. And -- stm >= ?.?.? is required for fast tryReadTChan, peekTChan,- -- tryPeekTChan.+ -- tryPeekTChan, tryReadTMVar, modifyTVar, modifyTVar', swapTVar. Build-Depends: base >= 4.1 && < 5 , stm >= 2.1.1 @@ -45,6 +45,7 @@ , Control.Concurrent.STM.TBMChan , Control.Concurrent.STM.TMChan , Control.Concurrent.STM.TChan.Compat+ , Control.Concurrent.STM.TMVar.Compat , Control.Concurrent.STM.TVar.Compat ----------------------------------------------------------------