@@ -286,19 +286,19 @@ dispatchWorkerPaced sv = do
286{-# NOINLINE sendWorkerWait #-}
286{-# NOINLINE sendWorkerWait #-}
287sendWorkerWait
287sendWorkerWait
288 :: MonadIO m
288 :: MonadIO m
289− => (Channel m a -> IO ())
290+ -> (Channel m a -> IO ())
290 -> (Channel m a -> m Bool)
291 -> (Channel m a -> m Bool)
291 -> Channel m a
292 -> Channel m a
293−sendWorkerWait delay dispatch sv = do
294+sendWorkerWait eager delay dispatch sv = do
294 -- Note that we are guaranteed to have at least one outstanding worker when
295 -- Note that we are guaranteed to have at least one outstanding worker when
295 -- we enter this function. So if we sleep we are guaranteed to be woken up
296 -- we enter this function. So if we sleep we are guaranteed to be woken up
296 -- by an outputDoorBell, when the worker exits.
297 -- by an outputDoorBell, when the worker exits.
298 liftIO $ delay sv
299 liftIO $ delay sv
299 (_, n) <- liftIO $ readIORef (outputQueue sv)
300 (_, n) <- liftIO $ readIORef (outputQueue sv)
300− -- XXX or eagerDispatch is true
301− when (n <= 0) $ do
301+ when (n <= 0 || eager) $ do
302 -- The queue may be empty temporarily if the worker has dequeued the
302 -- The queue may be empty temporarily if the worker has dequeued the
303 -- work item but has not enqueued the remaining part yet. For the same
303 -- work item but has not enqueued the remaining part yet. For the same
304 -- reason, a worker may come back if it tries to dequeue and finds the
304 -- reason, a worker may come back if it tries to dequeue and finds the
@@ -356,7 +356,7 @@ sendWorkerWait delay dispatch sv = do
356 -- forever.
356 -- forever.
358 if canDoMore
358 if canDoMore
359− then sendWorkerWait delay dispatch sv
359+ then sendWorkerWait eager delay dispatch sv
362 $ withDiagMVar
362 $ withDiagMVar
@@ -365,7 +365,7 @@ sendWorkerWait delay dispatch sv = do
365 "sendWorkerWait: nothing to do"
365 "sendWorkerWait: nothing to do"
366 $ takeMVar (outputDoorBell sv)
366 $ takeMVar (outputDoorBell sv)
367 (_, len) <- liftIO $ readIORef (outputQueue sv)
367 (_, len) <- liftIO $ readIORef (outputQueue sv)
368− when (len <= 0) $ sendWorkerWait delay dispatch sv
368+ when (len <= 0) $ sendWorkerWait eager delay dispatch sv
370-- | Start the evaluation of the channel's work queue by kicking off a worker.
370-- | Start the evaluation of the channel's work queue by kicking off a worker.
371-- Note: Work queue must not be empty otherwise the worker will exit without
371-- Note: Work queue must not be empty otherwise the worker will exit without