resourcet 1.1.8.1 → 1.1.9
raw patch · 3 files changed
+22/−8 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Control.Monad.Trans.Resource: resourceForkWith :: MonadBaseControl IO m => (IO () -> IO a) -> ResourceT m () -> ResourceT m a
- Control.Monad.Trans.Resource: throwM :: Exception e => e -> m a
+ Control.Monad.Trans.Resource: throwM :: (MonadThrow m, Exception e) => e -> m a
Files
- ChangeLog.md +4/−0
- Control/Monad/Trans/Resource.hs +17/−7
- resourcet.cabal +1/−1
ChangeLog.md view
@@ -1,3 +1,7 @@+## 1.1.9++* Add generalized version of resourceForkIO+ ## 1.1.8.1 * Allocation actions should be masked
Control/Monad/Trans/Resource.hs view
@@ -25,6 +25,7 @@ -- * Unwrap , runResourceT -- * Special actions+ , resourceForkWith , resourceForkIO -- * Monad transformation , transResourceT@@ -131,7 +132,7 @@ resourceMask r = liftResourceT (resourceMaskRIO r) allocateRIO :: IO a -> (a -> IO ()) -> ResourceT IO (ReleaseKey, a)-allocateRIO acquire rel = ResourceT $ \istate -> liftIO $ E.mask $ \restore -> do+allocateRIO acquire rel = ResourceT $ \istate -> liftIO $ E.mask_ $ do a <- acquire key <- register' istate $ rel a return (key, a)@@ -243,17 +244,20 @@ -- shared by multiple threads. Once the last thread exits, all remaining -- resources will be released. --+-- The first parameter is a function which will be used to create the+-- thread, such as @forkIO@ or @async@.+-- -- Note that abuse of this function will greatly delay the deallocation of -- registered resources. This function should be used with care. A general -- guideline: -- -- If you are allocating a resource that should be shared by multiple threads, -- and will be held for a long time, you should allocate it at the beginning of--- a new @ResourceT@ block and then call @resourceForkIO@ from there.+-- a new @ResourceT@ block and then call @resourceForkWith@ from there. ----- Since 0.3.0-resourceForkIO :: MonadBaseControl IO m => ResourceT m () -> ResourceT m ThreadId-resourceForkIO (ResourceT f) = ResourceT $ \r -> L.mask $ \restore ->+-- @since 1.1.9+resourceForkWith :: MonadBaseControl IO m => (IO () -> IO a) -> ResourceT m () -> ResourceT m a+resourceForkWith g (ResourceT f) = ResourceT $ \r -> L.mask $ \restore -> -- We need to make sure the counter is incremented before this call -- returns. Otherwise, the parent thread may call runResourceT before -- the child thread increments, and all resources will be freed@@ -262,13 +266,19 @@ (stateAlloc r) (return ()) (return ())- (liftBaseDiscard forkIO $ bracket_+ (liftBaseDiscard g $ bracket_ (return ()) (stateCleanup ReleaseNormal r) (stateCleanup ReleaseException r) (restore $ f r)) -+-- | Launch a new reference counted resource context using @forkIO@.+--+-- This is defined as @resourceForkWith forkIO@.+--+-- @since 0.3.0+resourceForkIO :: MonadBaseControl IO m => ResourceT m () -> ResourceT m ThreadId+resourceForkIO = resourceForkWith forkIO -- | A @Monad@ which can be used as a base for a @ResourceT@. --
resourcet.cabal view
@@ -1,5 +1,5 @@ Name: resourcet-Version: 1.1.8.1+Version: 1.1.9 Synopsis: Deterministic allocation and freeing of scarce resources. description: Hackage documentation generation is not reliable. For up to date documentation, please see: <http://www.stackage.org/package/resourcet>. License: BSD3