on master help sign in
Fix maxThreads being ignored
75fdf1fLuke Clifton
src/Streamly/SVar.hs+8−5
@@ -1426,10 +1426,13 @@ dispatchWorker yieldCount sv = do
1426 Nothing -> return workerLimit
1426 Nothing -> return workerLimit
1427 Just ref -> do
1427 Just ref -> do
1428 n <- liftIO $ readIORef ref
1428 n <- liftIO $ readIORef ref
1429+ case yieldRateInfo sv of
1429− return $
1430+ Just _ -> return workerLimit
1431+ Nothing ->
1432+ return $
1430− case workerLimit of
1433+ case workerLimit of
1431− Unlimited -> Limited (fromIntegral n)
1434+ Unlimited -> Limited (fromIntegral n)
1432− Limited lim -> Limited $ min lim (fromIntegral n)
1435+ Limited lim -> Limited $ min lim (fromIntegral n)
1433
1436
1434 -- XXX for ahead streams shall we take the heap yields into account
1437 -- XXX for ahead streams shall we take the heap yields into account
1435 -- for controlling the dispatch? We should not dispatch if the heap
1438 -- for controlling the dispatch? We should not dispatch if the heap
@@ -1442,7 +1445,7 @@ dispatchWorker yieldCount sv = do
1442 -- and using them here, so this is just approximate logic and
1445 -- and using them here, so this is just approximate logic and
1443 -- we cannot rely on it for correctness. We may actually
1446 -- we cannot rely on it for correctness. We may actually
1444 -- dispatch more workers than required.
1447 -- dispatch more workers than required.
1445− Limited lim | lim > 0 -> dispatch
1448+ Limited lim | lim > fromIntegral active -> dispatch
1446 _ -> return False
1449 _ -> return False
1447 else do
1450 else do
1448 when (active <= 0) $ pushWorker 0 sv
1451 when (active <= 0) $ pushWorker 0 sv