on master help sign in
Added comments.
commitc5d087130e42f26a5e548950f666bb247a4813c6 authorShlok Datye <shlok@quant.is> dateTue 10 Mar 2020, 23:19 (7 years ago) parent8f4f9ed
2 files changed+8
src/Streamly/Internal/Data/Stream/StreamD.hs+4 src/Streamly/Internal/Data/Unfold.hs+4
src/Streamly/Internal/Data/Stream/StreamD.hs+4
@@ -2951,6 +2951,10 @@ gbracketIO bef exc aft fexc fnormal =
29512951 -- weak pointer to us.
29522952 {-# INLINE_LATE step #-}
29532953 step _ GBracketIOInit = do
2954+ -- We mask asynchronous exceptions to make the execution
2955+ -- of 'bef' and the registration of 'aft' atomic.
2956+ -- A similar thing is done in the resourcet package: https://git.io/JvKV3
2957+ -- Tutorial: https://markkarpov.com/tutorial/exceptions.html
29542958 (r, ref) <- liftBaseOp_ mask_ $ do
29552959 r <- bef
29562960 ref <- newFinalizedIORef (aft r)
src/Streamly/Internal/Data/Unfold.hs+4
@@ -788,6 +788,8 @@ gbracketIO bef exc aft (Unfold estep einject) (Unfold step1 inject1) =
788788 where
789789
790790 inject x = do
791+ -- Mask asynchronous exceptions to make the execution of 'bef' and
792+ -- the registration of 'aft' atomic. See comment in 'D.gbracketIO'.
791793 (r, ref) <- liftBaseOp_ mask_ $ do
792794 r <- bef x
793795 ref <- D.newFinalizedIORef (aft r)
@@ -1040,6 +1042,8 @@ bracketIO bef aft (Unfold step1 inject1) = Unfold step inject
10401042 where
10411043
10421044 inject x = do
1045+ -- Mask asynchronous exceptions to make the execution of 'bef' and
1046+ -- the registration of 'aft' atomic. See comment in 'D.gbracketIO'.
10431047 (r, ref) <- liftBaseOp_ mask_ $ do
10441048 r <- bef x
10451049 ref <- D.newFinalizedIORef (aft r)