on master help sign in
remove redundant context passing
commit986498fc18a02427f5d62eab7d3007c25617d5b0 authorHarendra Kumar <harendra.kumar@gmail.com> dateFri 13 Oct 2017, 04:47 (9 years ago) parentb2ba739
1 file changed+7−7
src/Asyncly/AsyncT.hs+7−7
src/Asyncly/AsyncT.hs+7−7
@@ -387,14 +387,14 @@ sendWorkerWait ctx = dispatch >> void (liftIO $ takeMVar (doorBell ctx))
387387-- Note: This is performance sensitive code.
388388{-# NOINLINE pullWorker #-}
389389pullWorker :: MonadAsync m => Context m a -> AsyncT m a
390−pullWorker ctx = AsyncT $ \pctx stp yld -> do
390+pullWorker ctx = AsyncT $ \_ stp yld -> do
391391 res <- liftIO $ tryTakeMVar (doorBell ctx)
392392 when (isNothing res) $ sendWorkerWait ctx
393393 list <- liftIO $ atomicModifyIORefCAS (outputQueue ctx) $ \x -> ([], x)
394394 -- To avoid lock overhead we read all events at once instead of reading one
395395 -- at a time. We just reverse the list to process the events in the order
396396 -- they arrived. Maybe we can use a queue instead?
397− (runAsyncT $ processEvents pctx (reverse list)) Nothing stp yld
397+ (runAsyncT $ processEvents (reverse list)) Nothing stp yld
398398
399399 where
400400
@@ -405,15 +405,15 @@ pullWorker ctx = AsyncT $ \pctx stp yld -> do
405405 throwM e
406406
407407 {-# INLINE processEvents #-}
408− processEvents pctx [] = AsyncT $ \_ stp yld -> do
408+ processEvents [] = AsyncT $ \_ stp yld -> do
409409 done <- allThreadsDone ctx
410410 if not done
411− then (runAsyncT (pullWorker ctx)) pctx stp yld
411+ then (runAsyncT (pullWorker ctx)) Nothing stp yld
412412 else stp
413413
414− processEvents pctx (ev : es) = AsyncT $ \_ stp yld -> do
415− let continue = (runAsyncT (processEvents pctx es)) Nothing stp yld
416− yield a = yld a (Just (processEvents pctx es))
414+ processEvents (ev : es) = AsyncT $ \_ stp yld -> do
415+ let continue = (runAsyncT (processEvents es)) Nothing stp yld
416+ yield a = yld a (Just (processEvents es))
417417
418418 case ev of
419419 ChildYield a -> yield a