wip: explore removing delays(4)
This commit is contained in:
parent
a347c05062
commit
67ae171532
@ -156,11 +156,9 @@ fromStringWritable = unsafeCoerce
|
|||||||
|
|
||||||
awaitReadableOrClosed :: forall s a. Read s a => s -> Aff Unit
|
awaitReadableOrClosed :: forall s a. Read s a => s -> Aff Unit
|
||||||
awaitReadableOrClosed s = do
|
awaitReadableOrClosed s = do
|
||||||
closed <- liftEffect $ isClosed s
|
|
||||||
ended <- liftEffect $ isReadableEnded s
|
|
||||||
readable <- liftEffect $ isReadable s
|
readable <- liftEffect $ isReadable s
|
||||||
length <- liftEffect $ readableLength s
|
length <- liftEffect $ readableLength s
|
||||||
when (not ended && not closed && not readable && length > 0)
|
when (readable && length == 0)
|
||||||
$ liftEither
|
$ liftEither
|
||||||
=<< parOneOf
|
=<< parOneOf
|
||||||
[ onceAff0 readableH s $> Right unit
|
[ onceAff0 readableH s $> Right unit
|
||||||
@ -173,10 +171,9 @@ awaitFinished s = onceAff0 finishH s
|
|||||||
|
|
||||||
awaitWritableOrClosed :: forall s a. Write s a => s -> Aff Unit
|
awaitWritableOrClosed :: forall s a. Write s a => s -> Aff Unit
|
||||||
awaitWritableOrClosed s = do
|
awaitWritableOrClosed s = do
|
||||||
closed <- liftEffect $ isClosed s
|
|
||||||
ended <- liftEffect $ isWritableEnded s
|
|
||||||
writable <- liftEffect $ isWritable s
|
writable <- liftEffect $ isWritable s
|
||||||
when (not ended && not closed && not writable)
|
needsDrain <- liftEffect $ needsDrain s
|
||||||
|
when (writable && needsDrain)
|
||||||
$ liftEither =<< parOneOf [ onceAff0 drainH s $> Right unit, onceAff0 closeH s $> Right unit, Left <$> onceAff1 errorH s ]
|
$ liftEither =<< parOneOf [ onceAff0 drainH s $> Right unit, onceAff0 closeH s $> Right unit, Left <$> onceAff1 errorH s ]
|
||||||
|
|
||||||
onceAff0 :: forall e. EventHandle0 e -> e -> Aff Unit
|
onceAff0 :: forall e. EventHandle0 e -> e -> Aff Unit
|
||||||
|
Loading…
Reference in New Issue
Block a user