@@ -208,7 +208,7 @@ doFork action exHandler =
209{-# NOINLINE push #-}
209{-# NOINLINE push #-}
210push :: MonadAsync m => Context m a -> m ()
210push :: MonadAsync m => Context m a -> m ()
211−push ctx = run (Just ctx) (dequeueLoop ctx)
211+push ctx = run (Just ctx) (dequeueLoop (Just ctx) (workQueue ctx))
@@ -397,16 +397,16 @@ queueWork ctx m = do
398-- Note: This is performance sensitive code.
398-- Note: This is performance sensitive code.
399{-# INLINE dequeueLoop #-}
399{-# INLINE dequeueLoop #-}
400−dequeueLoop :: MonadAsync m => Context m a -> AsyncT m a
400+dequeueLoop :: MonadAsync m => Maybe (Context m a) -> TBQueue (AsyncT m a) -> AsyncT m a
401−dequeueLoop ctx = AsyncT $ \_ stp yld -> do
401+dequeueLoop ctx q = AsyncT $ \_ stp yld -> do
402− work <- liftIO $ atomically $ tryReadTBQueue (workQueue ctx)
402+ work <- liftIO $ atomically $ tryReadTBQueue q
403 case work of
403 case work of
404 Nothing -> stp
404 Nothing -> stp
405 Just m -> do
405 Just m -> do
406− let stop = (runAsyncT (dequeueLoop ctx)) Nothing stp yld
406+ let stop = (runAsyncT (dequeueLoop ctx q)) Nothing stp yld
407− yield a c Nothing = yld a c (Just (dequeueLoop ctx))
407+ yield a c Nothing = yld a c (Just (dequeueLoop ctx q))
408 yield a c r = yld a c r
408 yield a c r = yld a c r
409− (runAsyncT m) (Just ctx) stop yield
409+ (runAsyncT m) ctx stop yield
411instance MonadAsync m => Alternative (AsyncT m) where
411instance MonadAsync m => Alternative (AsyncT m) where
412 empty = mempty
412 empty = mempty
@@ -422,7 +422,7 @@ instance MonadAsync m => Alternative (AsyncT m) where
422 -- go left to right. If the left one keeps producing results we
422 -- go left to right. If the left one keeps producing results we
423 -- may or may not run the right one.
423 -- may or may not run the right one.
424 queueWork c m1 >> queueWork c m2
424 queueWork c m1 >> queueWork c m2
425− (runAsyncT (dequeueLoop c)) Nothing stp yld
425+ (runAsyncT (dequeueLoop ctx (workQueue c))) Nothing stp yld
427-- | Just like '<>' except that it can execute the action on the right in
427-- | Just like '<>' except that it can execute the action on the right in
428-- parallel ahead of time. Returns the results in serial order like '<>' from
428-- parallel ahead of time. Returns the results in serial order like '<>' from
@@ -447,7 +447,7 @@ parLeft m1 m2 = AsyncT $ \ctx stp yld -> do
447 -- go left to right. If the left one keeps producing results we
447 -- go left to right. If the left one keeps producing results we
448 -- may or may not run the right one.
448 -- may or may not run the right one.
449 queueWork c m1 >> queueWork c m2
449 queueWork c m1 >> queueWork c m2
450− (runAsyncT (dequeueLoop c)) Nothing stp yld
450+ (runAsyncT (dequeueLoop ctx (workQueue c))) Nothing stp yld
452-- | Same as 'parLeft'.
452-- | Same as 'parLeft'.
453{-# INLINE (<|) #-}
453{-# INLINE (<|) #-}