concurrent-extra 0.6 → 0.6.0.1
raw patch · 17 files changed
+174/−107 lines, 17 filesdep −QuickCheckdep −test-framework-quickcheck2
Dependencies removed: QuickCheck, test-framework-quickcheck2
Files
- Control/Concurrent/Broadcast.hs +23/−18
- Control/Concurrent/Event.hs +6/−4
- Control/Concurrent/Event/Test.hs +8/−8
- Control/Concurrent/Lock.hs +5/−1
- Control/Concurrent/Lock/Test.hs +7/−3
- Control/Concurrent/RLock.hs +9/−3
- Control/Concurrent/RLock/Test.hs +7/−2
- Control/Concurrent/ReadWriteLock.hs +9/−3
- Control/Concurrent/ReadWriteLock/Test.hs +6/−2
- Control/Concurrent/STM/Lock.hs +22/−14
- Control/Concurrent/STM/Lock/Test.hs +7/−2
- Control/Concurrent/Thread/Delay.hs +6/−2
- Control/Concurrent/Timeout.hs +21/−17
- Control/Concurrent/Timeout/Test.hs +10/−9
- TestUtils.hs +8/−3
- Utils.hs +13/−7
- concurrent-extra.cabal +7/−9
Control/Concurrent/Broadcast.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE DeriveDataTypeable, NoImplicitPrelude, UnicodeSyntax #-}+{-# LANGUAGE CPP, DeriveDataTypeable, NoImplicitPrelude, UnicodeSyntax #-} ------------------------------------------------------------------------------- -- |@@ -49,25 +49,30 @@ ------------------------------------------------------------------------------- -- from base:-import Control.Monad ( (>>=), (>>), return, fail, when )-import Control.Concurrent.MVar ( MVar, newMVar, newEmptyMVar- , takeMVar, putMVar, readMVar, modifyMVar_- )-import Control.Exception ( onException )-import Data.Eq ( Eq )-import Data.Either ( Either(Left ,Right), either )-import Data.Function ( ($), const )-import Data.Functor ( fmap, (<$>) )-import Data.Foldable ( for_ )-import Data.List ( delete, length )-import Data.Maybe ( Maybe(Nothing, Just), isNothing )-import Data.Ord ( Ord, max )-import Data.Typeable ( Typeable )-import Prelude ( Integer, fromInteger, seq )-import System.IO ( IO )+import Control.Monad ( return, when )+import Control.Concurrent.MVar ( MVar, newMVar, newEmptyMVar+ , takeMVar, putMVar, readMVar, modifyMVar_+ )+import Control.Exception ( onException )+import Data.Eq ( Eq )+import Data.Either ( Either(Left ,Right), either )+import Data.Function ( ($), const )+import Data.Functor ( fmap, (<$>) )+import Data.Foldable ( for_ )+import Data.List ( delete, length )+import Data.Maybe ( Maybe(Nothing, Just), isNothing )+import Data.Ord ( Ord, max )+import Data.Typeable ( Typeable )+import Prelude ( Integer, seq )+import System.IO ( IO ) +#if __GLASGOW_HASKELL__ < 701+import Prelude ( fromInteger )+import Control.Monad ( (>>=), (>>), fail )+#endif+ -- from base-unicode-symbols:-import Data.Function.Unicode ( (∘) )+import Data.Function.Unicode ( (∘) ) -- from concurrent-extra (this package): import Utils ( purelyModifyMVar, mask_ )
Control/Concurrent/Event.hs view
@@ -63,9 +63,11 @@ import Data.Functor ( fmap, (<$>) ) import Data.Maybe ( isJust ) import Data.Typeable ( Typeable )+ #ifdef __HADDOCK__ import Control.Exception ( block ) #endif+ import Prelude ( Integer ) import System.IO ( IO ) @@ -75,10 +77,10 @@ -- from concurrent-extra (this package): import Control.Concurrent.Broadcast ( Broadcast ) import qualified Control.Concurrent.Broadcast as Broadcast- ( new, newBroadcasting- , listen, tryListen, listenTimeout- , broadcast, signal, silence- )+ ( new, newBroadcasting+ , listen, tryListen, listenTimeout+ , broadcast, signal, silence+ ) -------------------------------------------------------------------------------
Control/Concurrent/Event/Test.hs view
@@ -1,7 +1,4 @@-{-# LANGUAGE NoImplicitPrelude- , UnicodeSyntax- , ScopedTypeVariables- #-}+{-# LANGUAGE CPP, NoImplicitPrelude, UnicodeSyntax, ScopedTypeVariables #-} module Control.Concurrent.Event.Test ( tests ) where @@ -12,12 +9,15 @@ -- from base: import Control.Exception ( catch, throwTo, ErrorCall(..) ) import Control.Concurrent ( forkIO )-import Control.Monad ( return, (>>=), fail, (>>)- , mapM_, replicateM, replicateM_- )+import Control.Monad ( return, mapM_, replicateM, replicateM_ ) import Data.Function ( ($) ) import Data.Int ( Int )-import Prelude ( fromInteger, toInteger )+import Prelude ( toInteger )++#if __GLASGOW_HASKELL__ < 701+import Prelude ( fromInteger )+import Control.Monad ( (>>=), (>>), fail )+#endif -- from base-unicode-symbols: import Prelude.Unicode ( (⋅) )
Control/Concurrent/Lock.hs view
@@ -63,7 +63,7 @@ , isEmptyMVar ) import Control.Exception ( bracket_, onException )-import Control.Monad ( Monad, return, (>>=), (>>), fail, when )+import Control.Monad ( Monad, return, (>>), when ) import Data.Bool ( Bool, not ) #ifdef __HADDOCK__ import Data.Bool ( Bool(False, True) )@@ -75,6 +75,10 @@ import Data.Typeable ( Typeable ) import Prelude ( error ) import System.IO ( IO )++#if __GLASGOW_HASKELL__ < 701+import Control.Monad ( (>>=), fail )+#endif -- from base-unicode-symbols: import Data.Function.Unicode ( (∘) )
Control/Concurrent/Lock/Test.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE NoImplicitPrelude+{-# LANGUAGE CPP+ , NoImplicitPrelude , UnicodeSyntax , ScopedTypeVariables #-}@@ -11,13 +12,16 @@ -- from base: import Control.Concurrent ( forkIO )-import Control.Monad ( return, (>>=), fail, (>>) )+import Control.Monad ( return, (>>=), (>>) ) import Data.Bool ( Bool(False, True), not, (&&) ) import Data.Function ( ($) ) import Data.Functor ( fmap ) import Data.IORef ( newIORef, writeIORef, readIORef )-import Prelude ( fromInteger ) +#if __GLASGOW_HASKELL__ < 701+import Prelude ( fromInteger )+import Control.Monad ( fail )+#endif -- from base-unicode-symbols: import Data.Function.Unicode ( (∘) )
Control/Concurrent/RLock.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE BangPatterns+{-# LANGUAGE CPP+ , BangPatterns , DeriveDataTypeable , NoImplicitPrelude , UnicodeSyntax@@ -66,7 +67,7 @@ import Control.Concurrent ( ThreadId, myThreadId ) import Control.Concurrent.MVar ( MVar, newMVar, takeMVar, readMVar, putMVar ) import Control.Exception ( bracket_, onException )-import Control.Monad ( Monad, return, (>>=), fail, (>>) )+import Control.Monad ( Monad, return, (>>) ) import Data.Bool ( Bool(False, True), otherwise ) import Data.Eq ( Eq ) import Data.Function ( ($) )@@ -74,8 +75,13 @@ import Data.Maybe ( Maybe(Nothing, Just) ) import Data.Tuple ( fst ) import Data.Typeable ( Typeable )-import Prelude ( Integer, fromInteger, succ, pred, error )+import Prelude ( Integer, succ, pred, error ) import System.IO ( IO )++#if __GLASGOW_HASKELL__ < 701+import Prelude ( fromInteger )+import Control.Monad ( fail, (>>=) )+#endif -- from base-unicode-symbols: import Data.Eq.Unicode ( (≡) )
Control/Concurrent/RLock/Test.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE NoImplicitPrelude+{-# LANGUAGE CPP+ , NoImplicitPrelude , UnicodeSyntax , ScopedTypeVariables #-}@@ -12,10 +13,14 @@ -- from base: import Control.Concurrent ( forkIO, threadDelay )-import Control.Monad ( (>>=), fail, (>>), replicateM_ )+import Control.Monad ( replicateM_ ) import Data.Function ( ($) ) import Data.Int ( Int )++#if __GLASGOW_HASKELL__ < 701 import Prelude ( fromInteger )+import Control.Monad ( (>>=), fail, (>>) )+#endif -- from base-unicode-symbols: import Data.Function.Unicode ( (∘) )
Control/Concurrent/ReadWriteLock.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE DeriveDataTypeable+{-# LANGUAGE CPP+ , DeriveDataTypeable , NamedFieldPuns , NoImplicitPrelude , UnicodeSyntax@@ -70,7 +71,7 @@ import Control.Applicative ( liftA2, liftA3 ) import Control.Concurrent.MVar ( MVar, newMVar, takeMVar, putMVar, swapMVar ) import Control.Exception ( bracket_, onException )-import Control.Monad ( return, (>>=), return, fail, (>>), when )+import Control.Monad ( return, return, (>>), when ) import Data.Bool ( Bool(False, True) ) import Data.Char ( String ) import Data.Eq ( Eq, (==) )@@ -78,8 +79,13 @@ import Data.Int ( Int ) import Data.Maybe ( Maybe(Nothing, Just) ) import Data.Typeable ( Typeable )-import Prelude ( ($!), fromInteger, succ, pred, error )+import Prelude ( ($!), succ, pred, error ) import System.IO ( IO )++#if __GLASGOW_HASKELL__ < 701+import Prelude ( fromInteger )+import Control.Monad ( (>>=), fail )+#endif -- from base-unicode-symbols: import Data.Function.Unicode ( (∘) )
Control/Concurrent/ReadWriteLock/Test.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE NoImplicitPrelude , UnicodeSyntax #-}+{-# LANGUAGE CPP, NoImplicitPrelude , UnicodeSyntax #-} module Control.Concurrent.ReadWriteLock.Test ( tests ) where @@ -8,10 +8,14 @@ ------------------------------------------------------------------------------- -- from base:-import Control.Monad ( (>>=), (>>), fail )+import Control.Monad ( (>>) ) import Control.Concurrent ( forkIO, threadDelay ) import Data.Function ( ($) )++#if __GLASGOW_HASKELL__ < 701 import Prelude ( fromInteger )+import Control.Monad ( (>>=), fail )+#endif -- from base-unicode-symbols: import Prelude.Unicode ( (⋅) )
Control/Concurrent/STM/Lock.hs view
@@ -46,26 +46,34 @@ -------------------------------------------------------------------------------- -- from base:-import Control.Applicative ( liftA2 )-import Control.Exception ( bracket_, onException )-import Control.Monad ( Monad, return, (>>=), (>>), fail, when )-import Data.Bool ( Bool, not )+import Control.Applicative ( liftA2 )+import Control.Exception ( bracket_, onException )+import Control.Monad ( Monad, return, (>>), when )+import Data.Bool ( Bool, not )+ #ifdef __HADDOCK__-import Data.Bool ( Bool(False, True) )+import Data.Bool ( Bool(False, True) ) #endif-import Data.Eq ( Eq )-import Data.Function ( ($) )-import Data.Functor ( fmap, (<$>) )-import Data.Maybe ( Maybe(Nothing, Just), isJust )-import Data.Typeable ( Typeable )-import Prelude ( error )-import System.IO ( IO ) +import Data.Eq ( Eq )+import Data.Function ( ($) )+import Data.Functor ( fmap, (<$>) )+import Data.Maybe ( Maybe(Nothing, Just), isJust )+import Data.Typeable ( Typeable )+import Prelude ( error )+import System.IO ( IO )++#if __GLASGOW_HASKELL__ < 701+import Control.Monad ( (>>=), fail )+#endif+ -- from stm: import Control.Concurrent.STM ( STM, atomically )+ #ifdef __HADDOCK__ import Control.Concurrent.STM ( retry ) #endif+ import Control.Concurrent.STM.TMVar ( TMVar, newTMVar, newEmptyTMVar , takeTMVar, tryTakeTMVar , putTMVar, tryPutTMVar@@ -73,10 +81,10 @@ ) -- from base-unicode-symbols:-import Data.Function.Unicode ( (∘) )+import Data.Function.Unicode ( (∘) ) -- from concurrent-extra (this package):-import Utils ( mask )+import Utils ( mask ) --------------------------------------------------------------------------------
Control/Concurrent/STM/Lock/Test.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE NoImplicitPrelude+{-# LANGUAGE CPP+ , NoImplicitPrelude , UnicodeSyntax , ScopedTypeVariables #-}@@ -11,12 +12,16 @@ -- from base: import Control.Concurrent ( forkIO )-import Control.Monad ( return, (>>=), fail, (>>) )+import Control.Monad ( return, (>>=), (>>) ) import Data.Bool ( Bool(False, True), not, (&&) ) import Data.Function ( ($) ) import Data.Functor ( fmap ) import Data.IORef ( newIORef, writeIORef, readIORef )++#if __GLASGOW_HASKELL__ < 701 import Prelude ( fromInteger )+import Control.Monad ( fail )+#endif -- from base-unicode-symbols: import Data.Function.Unicode ( (∘) )
Control/Concurrent/Thread/Delay.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE NoImplicitPrelude, UnicodeSyntax #-}+{-# LANGUAGE CPP, NoImplicitPrelude, UnicodeSyntax #-} ------------------------------------------------------------------------------- -- |@@ -20,12 +20,16 @@ -- from base: import Control.Concurrent ( threadDelay )-import Control.Monad ( (>>), when )+import Control.Monad ( when ) import Data.Function ( ($) ) import Data.Int ( Int ) import Data.Ord ( min ) import Prelude ( Integer, toInteger, fromInteger, maxBound, (-) ) import System.IO ( IO )++#if __GLASGOW_HASKELL__ < 701+import Control.Monad ( (>>) )+#endif -- from base-unicode-symbols: import Data.Eq.Unicode ( (≢) )
Control/Concurrent/Timeout.hs view
@@ -23,29 +23,33 @@ ------------------------------------------------------------------------------- -- from base:-import Control.Concurrent ( forkIO, myThreadId, throwTo, killThread )-import Control.Exception ( Exception, bracket, handleJust )-import Control.Monad ( return, (>>=), fail, (>>) )-import Data.Bool ( otherwise )-import Data.Eq ( Eq )-import Data.Functor ( fmap )-import Data.Maybe ( Maybe(Nothing, Just) )-import Data.Ord ( (<) )-import Data.Typeable ( Typeable )-import Data.Unique ( Unique, newUnique )-import Prelude ( Integer, fromInteger- )-import System.IO ( IO )-import Text.Show ( Show, show )+import Control.Concurrent ( forkIO, myThreadId, throwTo, killThread )+import Control.Exception ( Exception, bracket, handleJust )+import Control.Monad ( return, (>>) )+import Data.Bool ( otherwise )+import Data.Eq ( Eq )+import Data.Functor ( fmap )+import Data.Maybe ( Maybe(Nothing, Just) )+import Data.Ord ( (<) )+import Data.Typeable ( Typeable )+import Data.Unique ( Unique, newUnique )+import Prelude ( Integer )+import System.IO ( IO )+import Text.Show ( Show, show ) +#if __GLASGOW_HASKELL__ < 701+import Prelude ( fromInteger )+import Control.Monad ( (>>=), fail )+#endif+ #ifdef __HADDOCK__-import Data.Int ( Int )-import System.IO ( hGetBuf, hPutBuf, hWaitForInput )+import Data.Int ( Int )+import System.IO ( hGetBuf, hPutBuf, hWaitForInput ) import qualified System.Timeout ( timeout ) #endif -- from base-unicode-symbols:-import Data.Eq.Unicode ( (≡) )+import Data.Eq.Unicode ( (≡) ) -- from concurrent-extra (this package): import Control.Concurrent.Thread.Delay ( delay )
Control/Concurrent/Timeout/Test.hs view
@@ -1,6 +1,4 @@-{-# LANGUAGE NoImplicitPrelude- , UnicodeSyntax- #-}+{-# LANGUAGE CPP, NoImplicitPrelude, UnicodeSyntax #-} module Control.Concurrent.Timeout.Test ( tests ) where @@ -11,19 +9,22 @@ -- from base: import Control.Concurrent ( forkIO, killThread )-import Control.Exception ( block )-import Control.Monad ( (>>=), fail, (>>) ) import Data.Function ( ($) )-import Prelude ( fromInteger, toInteger )+import Prelude ( toInteger ) +#if __GLASGOW_HASKELL__ < 701+import Prelude ( fromInteger )+import Control.Monad ( (>>=), fail, (>>) )+#endif+ -- from base-unicode-symbols:-import Prelude.Unicode ( (⋅) )+import Prelude.Unicode ( (⋅) ) -- from concurrent-extra: import qualified Control.Concurrent.Lock as Lock import Control.Concurrent.Timeout ( timeout ) import TestUtils ( a_moment, within )-import Utils ( void )+import Utils ( void, mask_ ) -- from HUnit: import Test.HUnit ( Assertion, assert )@@ -45,7 +46,7 @@ test_timeout_exception ∷ Assertion test_timeout_exception = assert $ within (10 ⋅ a_moment) $ do l ← Lock.newAcquired- tid ← block $ forkIO $+ tid ← mask_ $ forkIO $ void $ timeout (toInteger $ 1000 ⋅ a_moment) $ Lock.acquire l killThread tid Lock.release l
TestUtils.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE NoImplicitPrelude+{-# LANGUAGE CPP+ , NoImplicitPrelude , ScopedTypeVariables , UnicodeSyntax #-}@@ -14,15 +15,19 @@ import Control.Applicative ( (<$>) ) import Control.Concurrent ( threadDelay ) import Control.Exception ( try, SomeException )-import Control.Monad ( (>>=), return, fail )+import Control.Monad ( return ) import Data.Bool ( Bool, not ) import Data.Char ( String ) import Data.Either ( Either(Left, Right) ) import Data.Int ( Int ) import Data.Maybe ( isJust )-import Prelude ( fromInteger ) import System.IO ( IO ) import System.Timeout ( timeout )++#if __GLASGOW_HASKELL__ < 701+import Prelude ( fromInteger )+import Control.Monad ( (>>=), fail )+#endif -- from HUnit: import Test.HUnit ( Assertion, assertFailure )
Utils.hs view
@@ -17,14 +17,17 @@ -- from base: import Control.Concurrent.MVar ( MVar, takeMVar, putMVar )-import Control.Monad ( Monad, return, (>>=), (>>), fail )+import Control.Monad ( Monad, return, (>>=) ) import Data.Bool ( Bool ) import Data.Function ( ($) )-import Data.Functor ( Functor, (<$) ) import Data.IORef ( IORef, readIORef, writeIORef ) import Prelude ( ($!) ) import System.IO ( IO ) +#if __GLASGOW_HASKELL__ < 701+import Control.Monad ( (>>), fail )+#endif+ -- from base-unicode-symbols: import Data.Function.Unicode ( (∘) ) @@ -34,23 +37,26 @@ -------------------------------------------------------------------------------- #if MIN_VERSION_base(4,3,0)-import Control.Exception ( mask, mask_ )+import Control.Exception ( mask, mask_ )+import Control.Monad ( void ) #else-import Control.Exception ( blocked, block, unblock )+import Control.Exception ( blocked, block, unblock )+import Data.Function ( id )+import Data.Functor ( Functor, (<$) ) mask ∷ ((IO α → IO α) → IO β) → IO β mask io = blocked >>= \b → if b then io id else block $ io unblock mask_ ∷ IO α → IO α mask_ = block++void ∷ Functor f ⇒ f α → f ()+void = (() <$) #endif -- | Strict function composition. (∘!) ∷ (β → γ) → (α → β) → (α → γ) f ∘! g = (f $!) ∘ g--void ∷ Functor f ⇒ f α → f ()-void = (() <$) ifM ∷ Monad m ⇒ m Bool → m α → m α → m α ifM c t e = c >>= \b → if b then t else e
concurrent-extra.cabal view
@@ -1,5 +1,5 @@ name: concurrent-extra-version: 0.6+version: 0.6.0.1 cabal-version: >= 1.6 build-type: Custom stability: experimental@@ -101,14 +101,12 @@ ghc-options: -Wall if flag(test)- build-depends: base >= 3 && < 4.4- , base-unicode-symbols >= 0.1.1 && < 0.3- , stm >= 2.1.2.1 && < 2.3- , HUnit >= 1.2.2 && < 1.3- , QuickCheck >= 2.1.0 && < 2.2- , test-framework >= 0.2.4 && < 0.4- , test-framework-hunit >= 0.2.4 && < 0.3- , test-framework-quickcheck2 >= 0.2.4 && < 0.3+ build-depends: base >= 3 && < 4.4+ , base-unicode-symbols >= 0.1.1 && < 0.3+ , stm >= 2.1.2.1 && < 2.3+ , HUnit >= 1.2.2 && < 1.3+ , test-framework >= 0.2.4 && < 0.4+ , test-framework-hunit >= 0.2.4 && < 0.3 buildable: True else buildable: False