on master help sign in
Do not add any dispatch delay in case of <|>
commitf7e771c898fe3de048a1407b7016e121339b3997 authorHarendra Kumar <harendra.kumar@gmail.com> dateSun 22 Oct 2017, 06:33 (9 years ago) parent0fec2e9
1 file changed+5−2
src/Asyncly/AsyncT.hs+5−2
src/Asyncly/AsyncT.hs+5−2
@@ -371,7 +371,10 @@ pushWorker ctx =
371371{-# INLINE sendWorkerWait #-}
372372sendWorkerWait :: MonadAsync m => Context m a -> m ()
373373sendWorkerWait ctx = do
374− liftIO $ threadDelay 200
374+ case ctxType ctx of
375+ CtxType _ LIFO -> liftIO $ threadDelay 200
376+ CtxType _ FIFO -> liftIO $ threadDelay 0
377+
375378 output <- liftIO $ readIORef (outputQueue ctx)
376379 when (null output) $ do
377380 done <- queueEmpty ctx
@@ -387,7 +390,7 @@ instance Exception ContextUsedAfterEOF
387390pullFromCtx :: MonadAsync m => Context m a -> AsyncT m a
388391pullFromCtx ctx = AsyncT $ \_ stp yld -> do
389392 -- When using an async handle to the context, one may keep using a stale
390− -- context even after it has been fullt drained. To detect it gracefully we
393+ -- context even after it has been fully drained. To detect it gracefully we
391394 -- raise an explicit exception.
392395 -- XXX if reading the IORef is costly we can use a flag in the context to
393396 -- indicate we are done.