wip: explore removing delays(8)
This commit is contained in:
parent
edc7d40dbc
commit
f9c0e20777
@ -13,6 +13,7 @@ import Data.Tuple.Nested ((/\))
|
|||||||
import Effect.Aff.Class (class MonadAff, liftAff)
|
import Effect.Aff.Class (class MonadAff, liftAff)
|
||||||
import Effect.Class (liftEffect)
|
import Effect.Class (liftEffect)
|
||||||
import Effect.Exception (Error)
|
import Effect.Exception (Error)
|
||||||
|
import Node.Stream.Object (needsDrain)
|
||||||
import Node.Stream.Object as O
|
import Node.Stream.Object as O
|
||||||
import Pipes (await, yield)
|
import Pipes (await, yield)
|
||||||
import Pipes (for) as P
|
import Pipes (for) as P
|
||||||
@ -108,7 +109,12 @@ fromTransform t =
|
|||||||
err <- liftEffect $ liftST $ STRef.read error
|
err <- liftEffect $ liftST $ STRef.read error
|
||||||
for_ err throwError
|
for_ err throwError
|
||||||
|
|
||||||
|
needsDrain <- liftEffect $ O.needsDrain t
|
||||||
|
if needsDrain then do
|
||||||
|
liftAff $ O.awaitReadableOrClosed t
|
||||||
yieldWhileReadable
|
yieldWhileReadable
|
||||||
|
pure $ Loop {error, cancel}
|
||||||
|
else do
|
||||||
ma <- await
|
ma <- await
|
||||||
case ma of
|
case ma of
|
||||||
Nothing -> cleanup cancel
|
Nothing -> cleanup cancel
|
||||||
@ -120,10 +126,7 @@ fromTransform t =
|
|||||||
maybeYield1
|
maybeYield1
|
||||||
pure $ Loop { error, cancel }
|
pure $ Loop { error, cancel }
|
||||||
O.WriteWouldBlock -> do
|
O.WriteWouldBlock -> do
|
||||||
queueLen <- liftEffect $ O.readableLength t
|
|
||||||
when (queueLen == 0) $ liftAff $ O.awaitReadableOrClosed t
|
|
||||||
yieldWhileReadable
|
yieldWhileReadable
|
||||||
liftAff $ O.awaitWritableOrClosed t
|
|
||||||
pure $ Loop { error, cancel }
|
pure $ Loop { error, cancel }
|
||||||
in
|
in
|
||||||
do
|
do
|
||||||
|
Loading…
Reference in New Issue
Block a user