fix: more yields
This commit is contained in:
parent
9d8b500b8d
commit
820351f800
@ -94,17 +94,21 @@ fromTransform t =
|
|||||||
liftEffect $ removeErrorListener
|
liftEffect $ removeErrorListener
|
||||||
fromReadable t
|
fromReadable t
|
||||||
pure $ Done unit
|
pure $ Done unit
|
||||||
yieldFromReadableHalf = do
|
yieldFromReadableHalf =
|
||||||
res <- liftEffect (O.read t)
|
flip tailRecM unit $ const do
|
||||||
case res of
|
res <- liftEffect (O.read t)
|
||||||
O.ReadJust a -> yield (Just a) *> yieldFromReadableHalf
|
case res of
|
||||||
O.ReadWouldBlock -> pure unit
|
O.ReadJust a -> do
|
||||||
O.ReadClosed -> yield Nothing *> pure unit
|
yield $ Just a
|
||||||
|
pure $ Loop unit
|
||||||
|
O.ReadWouldBlock -> pure $ Done unit
|
||||||
|
O.ReadClosed -> yield Nothing $> Done unit
|
||||||
go { error, cancel } = do
|
go { error, cancel } = do
|
||||||
liftAff $ delay $ wrap 0.0
|
liftAff $ delay $ wrap 0.0
|
||||||
err <- liftEffect $ liftST $ STRef.read error
|
err <- liftEffect $ liftST $ STRef.read error
|
||||||
for_ err throwError
|
for_ err throwError
|
||||||
|
|
||||||
|
yieldFromReadableHalf
|
||||||
ma <- await
|
ma <- await
|
||||||
case ma of
|
case ma of
|
||||||
Nothing -> cleanup cancel
|
Nothing -> cleanup cancel
|
||||||
|
Loading…
Reference in New Issue
Block a user