@@ -276,9 +276,7 @@ sendWorkerWait ctx = do
276 when (not workQEmpty && outQEmpty) $ pushWorker ctx
276 when (not workQEmpty && outQEmpty) $ pushWorker ctx
277 void $ liftIO $ atomically $ peekTBQueue (outputQueue ctx)
277 void $ liftIO $ atomically $ peekTBQueue (outputQueue ctx)
279−-- We re-raise any exceptions received from the child threads, that way
279+-- Note: This is performance sensitive code.
280−-- exceptions get propagated to the top level computation and can be handled
282{-# NOINLINE pullWorker #-}
280{-# NOINLINE pullWorker #-}
283pullWorker :: MonadAsync m => Context m a -> AsyncT m a
281pullWorker :: MonadAsync m => Context m a -> AsyncT m a
284pullWorker ctx = AsyncT $ \pctx stp yld -> do
282pullWorker ctx = AsyncT $ \pctx stp yld -> do
@@ -375,13 +373,14 @@ pullFork m1 m2 = AsyncT $ \_ stp yld -> do
375-- residual work back to the dispatcher. It will also consume a lot of
373-- residual work back to the dispatcher. It will also consume a lot of
376-- memory due to queueing of all the work before execution starts.
374-- memory due to queueing of all the work before execution starts.
378−{-# INLINE forkWorker #-}
376+{-# NOINLINE forkWorker #-}
379forkWorker :: MonadAsync m => Context m a -> m ()
377forkWorker :: MonadAsync m => Context m a -> m ()
380forkWorker ctx = do
378forkWorker ctx = do
381 let q = outputQueue ctx
379 let q = outputQueue ctx
382 tid <- doFork (push ctx) (handleChildException q)
380 tid <- doFork (push ctx) (handleChildException q)
383 liftIO $ atomically $ writeTBQueue q (ChildCreate tid)
381 liftIO $ atomically $ writeTBQueue q (ChildCreate tid)
383+-- Note: This is performance sensitive code.
385{-# INLINE queueWork #-}
384{-# INLINE queueWork #-}
386queueWork :: MonadAsync m => Context m a -> AsyncT m a -> m ()
385queueWork :: MonadAsync m => Context m a -> AsyncT m a -> m ()
387queueWork ctx m = do
386queueWork ctx m = do
@@ -396,6 +395,7 @@ queueWork ctx m = do
396 when (workQFull) $ forkWorker ctx
395 when (workQFull) $ forkWorker ctx
397 liftIO $ atomically $ writeTBQueue (workQueue ctx) m
396 liftIO $ atomically $ writeTBQueue (workQueue ctx) m
398+-- Note: This is performance sensitive code.
399{-# INLINE dequeueLoop #-}
399{-# INLINE dequeueLoop #-}
400dequeueLoop :: MonadAsync m => Context m a -> AsyncT m a
400dequeueLoop :: MonadAsync m => Context m a -> AsyncT m a
401dequeueLoop ctx = AsyncT $ \_ stp yld -> do
401dequeueLoop ctx = AsyncT $ \_ stp yld -> do