broadcast-chan-conduit 0.2.0.2 → 0.2.1
raw patch · 3 files changed
+38/−15 lines, 3 filesdep ~broadcast-chanPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: broadcast-chan
API changes (from Hackage documentation)
- BroadcastChan.Conduit: Handle :: a -> SomeException -> m Action -> Handler a
+ BroadcastChan.Conduit: Handle :: (a -> SomeException -> m Action) -> Handler a
- BroadcastChan.Conduit: data Handler (m :: * -> *) a
+ BroadcastChan.Conduit: data Handler (m :: Type -> Type) a
- BroadcastChan.Conduit: foldBChan :: (MonadIO m, MonadIO n) => x -> a -> x -> x -> x -> b -> BroadcastChan d a -> n m b
+ BroadcastChan.Conduit: foldBChan :: (MonadIO m, MonadIO n) => (x -> a -> x) -> x -> (x -> b) -> BroadcastChan d a -> n (m b)
- BroadcastChan.Conduit: foldBChanM :: (MonadIO m, MonadIO n) => x -> a -> m x -> m x -> x -> m b -> BroadcastChan d a -> n m b
+ BroadcastChan.Conduit: foldBChanM :: (MonadIO m, MonadIO n) => (x -> a -> m x) -> m x -> (x -> m b) -> BroadcastChan d a -> n (m b)
- BroadcastChan.Conduit: newBChanListener :: MonadIO m => BroadcastChan dir a -> m BroadcastChan Out a
+ BroadcastChan.Conduit: newBChanListener :: MonadIO m => BroadcastChan dir a -> m (BroadcastChan Out a)
- BroadcastChan.Conduit: newBroadcastChan :: MonadIO m => m BroadcastChan In a
+ BroadcastChan.Conduit: newBroadcastChan :: MonadIO m => m (BroadcastChan In a)
- BroadcastChan.Conduit.Throw: Handle :: a -> SomeException -> m Action -> Handler a
+ BroadcastChan.Conduit.Throw: Handle :: (a -> SomeException -> m Action) -> Handler a
- BroadcastChan.Conduit.Throw: data Handler (m :: * -> *) a
+ BroadcastChan.Conduit.Throw: data Handler (m :: Type -> Type) a
- BroadcastChan.Conduit.Throw: foldBChan :: (MonadIO m, MonadIO n) => x -> a -> x -> x -> x -> b -> BroadcastChan d a -> n m b
+ BroadcastChan.Conduit.Throw: foldBChan :: (MonadIO m, MonadIO n) => (x -> a -> x) -> x -> (x -> b) -> BroadcastChan d a -> n (m b)
- BroadcastChan.Conduit.Throw: foldBChanM :: (MonadIO m, MonadIO n) => x -> a -> m x -> m x -> x -> m b -> BroadcastChan d a -> n m b
+ BroadcastChan.Conduit.Throw: foldBChanM :: (MonadIO m, MonadIO n) => (x -> a -> m x) -> m x -> (x -> m b) -> BroadcastChan d a -> n (m b)
- BroadcastChan.Conduit.Throw: newBChanListener :: MonadIO m => BroadcastChan dir a -> m BroadcastChan Out a
+ BroadcastChan.Conduit.Throw: newBChanListener :: MonadIO m => BroadcastChan dir a -> m (BroadcastChan Out a)
- BroadcastChan.Conduit.Throw: newBroadcastChan :: MonadIO m => m BroadcastChan In a
+ BroadcastChan.Conduit.Throw: newBroadcastChan :: MonadIO m => m (BroadcastChan In a)
Files
- BroadcastChan/Conduit/Internal.hs +29/−8
- CHANGELOG.md +6/−0
- broadcast-chan-conduit.cabal +3/−7
BroadcastChan/Conduit/Internal.hs view
@@ -5,17 +5,18 @@ import Control.Monad ((>=>)) import Control.Monad.Trans.Resource (MonadResource)+import qualified Control.Monad.Trans.Resource as Resource+import qualified Control.Monad.Trans.Resource.Internal as ResourceI import Control.Monad.Trans.Class (lift) import Control.Monad.IO.Unlift (MonadUnliftIO(askUnliftIO), UnliftIO(..))-import Data.Acquire- (ReleaseType(ReleaseException), allocateAcquire, mkAcquireType)+import Data.Acquire (ReleaseType(..), allocateAcquire, mkAcquireType) import Data.Conduit import qualified Data.Conduit.List as C import Data.Foldable (traverse_) import Data.Void (Void) -import BroadcastChan.Extra- (BracketOnError(..), Handler, mapHandler, runParallel, runParallel_)+import BroadcastChan.Extra (BracketOnError(..), Handler, ThreadBracket(..))+import qualified BroadcastChan.Extra as Extra bracketOnError :: MonadResource m => IO a -> (a -> IO ()) -> m r -> m r bracketOnError alloc clean work =@@ -40,9 +41,19 @@ parMapM hnd threads workFun = do UnliftIO runInIO <- lift askUnliftIO - Bracket{allocate,cleanup,action} <- runParallel+ resourceState <- Resource.liftResourceT Resource.getInternalState++ let threadBracket = ThreadBracket+ { setupFork = ResourceI.stateAlloc resourceState+ , cleanupFork = ResourceI.stateCleanup ReleaseNormal resourceState+ , cleanupForkError =+ ResourceI.stateCleanup ReleaseException resourceState+ }++ Bracket{allocate,cleanup,action} <- Extra.runParallelWith+ threadBracket (Left yield)- (mapHandler runInIO hnd)+ (Extra.mapHandler runInIO hnd) threads (runInIO . workFun) body@@ -70,8 +81,18 @@ parMapM_ hnd threads workFun = do UnliftIO runInIO <- lift askUnliftIO - Bracket{allocate,cleanup,action} <- runParallel_- (mapHandler runInIO hnd)+ resourceState <- Resource.liftResourceT Resource.getInternalState++ let threadBracket = ThreadBracket+ { setupFork = ResourceI.stateAlloc resourceState+ , cleanupFork = ResourceI.stateCleanup ReleaseNormal resourceState+ , cleanupForkError =+ ResourceI.stateCleanup ReleaseException resourceState+ }++ Bracket{allocate,cleanup,action} <- Extra.runParallelWith_+ threadBracket+ (Extra.mapHandler runInIO hnd) threads (runInIO . workFun) C.mapM_
CHANGELOG.md view
@@ -1,3 +1,9 @@+0.2.1 [2019.11.17]+------------------+* Fix resource management bug resulting from using `MonadUnliftIO` to run+ `MonadResource` code in multiple threads. This version properly increments+ resource count for every thread.+ 0.2.0.2 [2019.03.30] -------------------- * Update bounds for GHC 8.6
broadcast-chan-conduit.cabal view
@@ -1,5 +1,5 @@ Name: broadcast-chan-conduit-Version: 0.2.0.2+Version: 0.2.1 Homepage: https://github.com/merijn/broadcast-chan Bug-Reports: https://github.com/merijn/broadcast-chan/issues@@ -15,7 +15,7 @@ Cabal-Version: >= 1.10 Build-Type: Simple Tested-With: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2,- GHC == 8.4.4, GHC == 8.6.4+ GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.1 Extra-Source-Files: CHANGELOG.md @@ -39,7 +39,7 @@ Trustworthy Build-Depends: base >= 4.7 && < 5- , broadcast-chan == 0.2.0.*+ , broadcast-chan == 0.2.1.* , conduit >= 1.2 && < 1.4 , resourcet >= 1.1 && < 1.3 , transformers >= 0.2 && < 0.6@@ -64,7 +64,3 @@ Source-Repository head Type: git Location: ssh://github.com:merijn/broadcast-chan.git--Source-Repository head- Type: mercurial- Location: https://bitbucket.org/merijnv/broadcast-chan