-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include fixes for version 0.2 into master.
- Loading branch information
Showing
22 changed files
with
167 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
------------------------------------------------------------------------------- | ||
-- | | ||
-- Module : BroadcastChan.Conduit | ||
-- Copyright : (C) 2014-2020 Merijn Verstraaten | ||
-- Copyright : (C) 2014-2021 Merijn Verstraaten | ||
-- License : BSD-style (see the file LICENSE) | ||
-- Maintainer : Merijn Verstraaten <[email protected]> | ||
-- Stability : experimental | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
------------------------------------------------------------------------------- | ||
-- | | ||
-- Module : BroadcastChan.Conduit.Throw | ||
-- Copyright : (C) 2014-2020 Merijn Verstraaten | ||
-- Copyright : (C) 2014-2021 Merijn Verstraaten | ||
-- License : BSD-style (see the file LICENSE) | ||
-- Maintainer : Merijn Verstraaten <[email protected]> | ||
-- Stability : experimental | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Copyright (c) 2013-2020, Merijn Verstraaten | ||
Copyright (c) 2013-2021, Merijn Verstraaten | ||
|
||
All rights reserved. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Cabal-Version: 2.2 | ||
Name: broadcast-chan-conduit | ||
Version: 0.3.0 | ||
|
||
|
@@ -6,16 +7,15 @@ Bug-Reports: https://github.com/merijn/broadcast-chan/issues | |
|
||
Author: Merijn Verstraaten | ||
Maintainer: Merijn Verstraaten <[email protected]> | ||
Copyright: Copyright © 2014-2020 Merijn Verstraaten | ||
Copyright: Copyright © 2014-2021 Merijn Verstraaten | ||
|
||
License: BSD3 | ||
License: BSD-3-Clause | ||
License-File: LICENSE | ||
|
||
Category: System | ||
Cabal-Version: >= 1.10 | ||
Build-Type: Simple | ||
Tested-With: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, | ||
GHC == 8.8.4, GHC == 8.10.2 | ||
GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.1, GHC == 9.2.1 | ||
|
||
Extra-Source-Files: CHANGELOG.md | ||
|
||
|
@@ -38,11 +38,11 @@ Library | |
ScopedTypeVariables | ||
Trustworthy | ||
|
||
Build-Depends: base >= 4.8 && < 4.15 | ||
Build-Depends: base >= 4.8 && < 4.17 | ||
, broadcast-chan == 0.3.0.* | ||
, conduit >= 1.2 && < 1.4 | ||
, resourcet >= 1.1 && < 1.3 | ||
, transformers >= 0.2 && < 0.6 | ||
, transformers >= 0.2 && < 0.7 | ||
, unliftio-core >= 0.1 && < 0.3 | ||
|
||
Test-Suite conduit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
------------------------------------------------------------------------------- | ||
-- | | ||
-- Module : BroadcastChan.Pipes | ||
-- Copyright : (C) 2014-2020 Merijn Verstraaten | ||
-- Copyright : (C) 2014-2021 Merijn Verstraaten | ||
-- License : BSD-style (see the file LICENSE) | ||
-- Maintainer : Merijn Verstraaten <[email protected]> | ||
-- Stability : experimental | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
------------------------------------------------------------------------------- | ||
-- | | ||
-- Module : BroadcastChan.Pipes.Throw | ||
-- Copyright : (C) 2014-2020 Merijn Verstraaten | ||
-- Copyright : (C) 2014-2021 Merijn Verstraaten | ||
-- License : BSD-style (see the file LICENSE) | ||
-- Maintainer : Merijn Verstraaten <[email protected]> | ||
-- Stability : experimental | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Copyright (c) 2013-2020, Merijn Verstraaten | ||
Copyright (c) 2013-2021, Merijn Verstraaten | ||
|
||
All rights reserved. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Cabal-Version: 2.2 | ||
Name: broadcast-chan-pipes | ||
Version: 0.3.0 | ||
|
||
|
@@ -6,16 +7,15 @@ Bug-Reports: https://github.com/merijn/broadcast-chan/issues | |
|
||
Author: Merijn Verstraaten | ||
Maintainer: Merijn Verstraaten <[email protected]> | ||
Copyright: Copyright © 2014-2020 Merijn Verstraaten | ||
Copyright: Copyright © 2014-2021 Merijn Verstraaten | ||
|
||
License: BSD3 | ||
License: BSD-3-Clause | ||
License-File: LICENSE | ||
|
||
Category: System | ||
Cabal-Version: >= 1.10 | ||
Build-Type: Simple | ||
Tested-With: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, | ||
GHC == 8.8.4, GHC == 8.10.2 | ||
GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.1, GHC == 9.2.1 | ||
|
||
Synopsis: Pipes-based parallel streaming code for broadcast-chan | ||
|
||
|
@@ -35,7 +35,7 @@ Library | |
Safe | ||
ScopedTypeVariables | ||
|
||
Build-Depends: base >= 4.8 && < 4.15 | ||
Build-Depends: base >= 4.8 && < 4.17 | ||
, broadcast-chan == 0.3.0.* | ||
, pipes >= 4.1.6 && < 4.4 | ||
, pipes-safe >= 2.2 && < 2.4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
------------------------------------------------------------------------------- | ||
-- | | ||
-- Module : BroadcastChan.Test | ||
-- Copyright : (C) 2014-2020 Merijn Verstraaten | ||
-- Copyright : (C) 2014-2021 Merijn Verstraaten | ||
-- License : BSD-style (see the file LICENSE) | ||
-- Maintainer : Merijn Verstraaten <[email protected]> | ||
-- Stability : experimental | ||
|
@@ -26,9 +26,10 @@ module BroadcastChan.Test | |
) where | ||
|
||
import Prelude hiding (seq) | ||
import Control.Concurrent (setNumCapabilities, threadDelay) | ||
import Control.Concurrent (forkIO, setNumCapabilities, threadDelay) | ||
import Control.Concurrent.Async (wait, withAsync) | ||
import Control.Concurrent.MVar | ||
import Control.Concurrent.QSemN | ||
import Control.Concurrent.STM | ||
import Control.Monad (void, when) | ||
import Control.Monad.IO.Class (MonadIO(liftIO)) | ||
|
@@ -98,6 +99,14 @@ doDrop predicate hnd val | |
| predicate val = throwIO TestException | ||
| otherwise = doPrint hnd val | ||
|
||
doRace :: MVar () -> QSemN -> a -> IO a | ||
doRace mvar sem _ = do | ||
result <- tryReadMVar mvar | ||
case result of | ||
Nothing -> signalQSemN sem 1 >> readMVar mvar | ||
Just () -> return () | ||
throwIO TestException | ||
|
||
fromTimeSpec :: Fractional n => TimeSpec -> n | ||
fromTimeSpec = fromIntegral . toNanoSecs | ||
|
||
|
@@ -247,6 +256,20 @@ terminationTest parImpl = testCase "termination" $ | |
withSystemTempFile "terminate.out" $ \_ hndl -> | ||
parImpl (Simple Terminate) [1..100] (doDrop even hndl) 4 | ||
|
||
raceTest | ||
:: (Handler IO Int -> [Int] -> (Int -> IO Int) -> Int -> IO r) -> TestTree | ||
raceTest parImpl = testCase "race" $ | ||
expect TestException . void $ do | ||
sem <- newQSemN 0 | ||
mvar <- newEmptyMVar | ||
forkIO $ do | ||
waitQSemN sem parCount | ||
putMVar mvar () | ||
parImpl (Simple Terminate) [1..100] (doRace mvar sem) parCount | ||
where | ||
parCount :: Int | ||
parCount = 4 | ||
|
||
retryTest | ||
:: (Eq r, Show r) | ||
=> ([Int] -> (Int -> IO Int) -> IO r) | ||
|
@@ -278,7 +301,7 @@ retryTest seqImpl parImpl = withRetryCheck $ \getRetryCheck -> | |
dropAfterPrint checkPresence hnd val = do | ||
hPrint hnd val | ||
when (even val) $ do | ||
isNotPresent <- checkPresence >>= ($val) | ||
isNotPresent <- checkPresence >>= ($ val) | ||
when isNotPresent $ throwIO TestException | ||
return val | ||
|
||
|
@@ -321,15 +344,19 @@ genStreamTests name seq par = askOption $ \(SlowTests slow) -> | |
bigInputs | slow = derivedParam (enumFromTo 0) "inputs" [600] | ||
| otherwise = derivedParam (enumFromTo 0) "inputs" [300] | ||
smallInputs = derivedParam (enumFromTo 0) "inputs" [0,1,2] | ||
pause = simpleParam "pause" [10^(5 :: Int)] | ||
pause = simpleParam "pause" [10^(4 :: Int)] | ||
|
||
in testGroup name | ||
[ testTree "output" (outputTest seq (par term)) $ | ||
threads . paramSets [ smallInputs, bigInputs ] | ||
, testTree "speedup" (speedupTest getCache seq (par term)) $ | ||
threads . bigInputs . pause | ||
, testGroup "exceptions" | ||
[ dropTest seq par, terminationTest par, retryTest seq par ] | ||
[ dropTest seq par | ||
, terminationTest par | ||
, raceTest par | ||
, retryTest seq par | ||
] | ||
] | ||
where | ||
term = Simple Terminate | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Copyright (c) 2013-2020, Merijn Verstraaten | ||
Copyright (c) 2013-2021, Merijn Verstraaten | ||
|
||
All rights reserved. | ||
|
||
|
Oops, something went wrong.