mirror of
https://github.com/haskell-effectful/effectful.git
synced 2024-12-18 11:31:38 +03:00
Consistently call the unmasking function unmask instead of restore
This commit is contained in:
parent
3e6fb33f33
commit
6f60a1e30c
@ -235,16 +235,16 @@ instance C.MonadCatch (Eff es) where
|
||||
unEff (handler e) es
|
||||
|
||||
instance C.MonadMask (Eff es) where
|
||||
mask k = unsafeEff $ \es -> E.mask $ \restore ->
|
||||
unEff (k $ \m -> unsafeEff $ restore . unEff m) es
|
||||
mask k = unsafeEff $ \es -> E.mask $ \unmask ->
|
||||
unEff (k $ \m -> unsafeEff $ unmask . unEff m) es
|
||||
|
||||
uninterruptibleMask k = unsafeEff $ \es -> E.uninterruptibleMask $ \restore ->
|
||||
unEff (k $ \m -> unsafeEff $ restore . unEff m) es
|
||||
uninterruptibleMask k = unsafeEff $ \es -> E.uninterruptibleMask $ \unmask ->
|
||||
unEff (k $ \m -> unsafeEff $ unmask . unEff m) es
|
||||
|
||||
generalBracket acquire release use = unsafeEff $ \es -> E.mask $ \restore -> do
|
||||
generalBracket acquire release use = unsafeEff $ \es -> E.mask $ \unmask -> do
|
||||
size <- sizeEnv es
|
||||
resource <- unEff acquire es
|
||||
b <- restore (unEff (use resource) es) `E.catch` \e -> do
|
||||
b <- unmask (unEff (use resource) es) `E.catch` \e -> do
|
||||
checkSizeEnv size es
|
||||
_ <- unEff (release resource $ C.ExitCaseException e) es
|
||||
E.throwIO e
|
||||
|
@ -75,9 +75,9 @@ tell w = stateStaticRep $ \(Writer w0) -> ((), Writer (w0 <> w))
|
||||
-- :}
|
||||
-- "Hi there!"
|
||||
listen :: (Writer w :> es, Monoid w) => Eff es a -> Eff es (a, w)
|
||||
listen m = unsafeEff $ \es -> mask $ \restore -> do
|
||||
listen m = unsafeEff $ \es -> mask $ \unmask -> do
|
||||
w0 <- stateEnv es $ \(Writer w) -> (w, Writer mempty)
|
||||
a <- restore (unEff m es) `onException` merge es w0
|
||||
a <- unmask (unEff m es) `onException` merge es w0
|
||||
(a, ) <$> merge es w0
|
||||
where
|
||||
merge es w0 =
|
||||
|
@ -83,11 +83,11 @@ listen m = unsafeEff $ \es -> do
|
||||
-- The mask is uninterruptible because modifyMVar_ v0 in the merge function
|
||||
-- might block and if an async exception is received while waiting, w1 will be
|
||||
-- lost.
|
||||
uninterruptibleMask $ \restore -> do
|
||||
uninterruptibleMask $ \unmask -> do
|
||||
v1 <- newMVar mempty
|
||||
-- Replace thread local MVar with a fresh one for isolated listening.
|
||||
v0 <- stateEnv es $ \(Writer v) -> (v, Writer v1)
|
||||
a <- restore (unEff m es) `onException` merge es v0 v1
|
||||
a <- unmask (unEff m es) `onException` merge es v0 v1
|
||||
(a, ) <$> merge es v0 v1
|
||||
where
|
||||
-- Merge results accumulated in the local MVar with the mainline. If an
|
||||
|
@ -38,9 +38,9 @@ runResource :: IOE :> es => Eff (Resource : es) a -> Eff es a
|
||||
runResource m = unsafeEff $ \es0 -> do
|
||||
size0 <- sizeEnv es0
|
||||
istate <- R.createInternalState
|
||||
mask $ \restore -> do
|
||||
mask $ \unmask -> do
|
||||
es <- unsafeConsEnv (Resource istate) dummyRelinker es0
|
||||
a <- restore (unEff m es) `catch` \e -> do
|
||||
a <- unmask (unEff m es) `catch` \e -> do
|
||||
unsafeTailEnv size0 es
|
||||
RI.stateCleanupChecked (Just e) istate
|
||||
throwIO e
|
||||
|
Loading…
Reference in New Issue
Block a user