on master help sign in
remove redundant context passing
986498fHarendra Kumar
src/Asyncly/AsyncT.hs+7−7
@@ -387,14 +387,14 @@ sendWorkerWait ctx = dispatch >> void (liftIO $ takeMVar (doorBell ctx))
387-- Note: This is performance sensitive code.
387-- Note: This is performance sensitive code.
388{-# NOINLINE pullWorker #-}
388{-# NOINLINE pullWorker #-}
389pullWorker :: MonadAsync m => Context m a -> AsyncT m a
389pullWorker :: MonadAsync m => Context m a -> AsyncT m a
390−pullWorker ctx = AsyncT $ \pctx stp yld -> do
390+pullWorker ctx = AsyncT $ \_ stp yld -> do
391 res <- liftIO $ tryTakeMVar (doorBell ctx)
391 res <- liftIO $ tryTakeMVar (doorBell ctx)
392 when (isNothing res) $ sendWorkerWait ctx
392 when (isNothing res) $ sendWorkerWait ctx
393 list <- liftIO $ atomicModifyIORefCAS (outputQueue ctx) $ \x -> ([], x)
393 list <- liftIO $ atomicModifyIORefCAS (outputQueue ctx) $ \x -> ([], x)
394 -- To avoid lock overhead we read all events at once instead of reading one
394 -- To avoid lock overhead we read all events at once instead of reading one
395 -- at a time. We just reverse the list to process the events in the order
395 -- at a time. We just reverse the list to process the events in the order
396 -- they arrived. Maybe we can use a queue instead?
396 -- 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
398
398
399 where
399 where
400
400
@@ -405,15 +405,15 @@ pullWorker ctx = AsyncT $ \pctx stp yld -> do
405 throwM e
405 throwM e
406
406
407 {-# INLINE processEvents #-}
407 {-# INLINE processEvents #-}
408− processEvents pctx [] = AsyncT $ \_ stp yld -> do
408+ processEvents [] = AsyncT $ \_ stp yld -> do
409 done <- allThreadsDone ctx
409 done <- allThreadsDone ctx
410 if not done
410 if not done
411− then (runAsyncT (pullWorker ctx)) pctx stp yld
411+ then (runAsyncT (pullWorker ctx)) Nothing stp yld
412 else stp
412 else stp
413
413
414− processEvents pctx (ev : es) = AsyncT $ \_ stp yld -> do
414+ processEvents (ev : es) = AsyncT $ \_ stp yld -> do
415− let continue = (runAsyncT (processEvents pctx es)) Nothing stp yld
415+ let continue = (runAsyncT (processEvents es)) Nothing stp yld
416− yield a = yld a (Just (processEvents pctx es))
416+ yield a = yld a (Just (processEvents es))
417
417
418 case ev of
418 case ev of
419 ChildYield a -> yield a
419 ChildYield a -> yield a