Commit 8664117b authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Move threadDelay for gcThread at the beginning

This commit moves the `threadDelay` present in the `gcThread` function
at the beginning of the `go` aux rather than at the end. This has the
effect that the first GC happens _after_ the delay time and not
immediately, which might make some tests unpredictable if we get unlucky
and some job ids are removed from the underlying map before we can
inspect their state.
parent 3d3e0122
Pipeline #4400 passed with stage
in 28 seconds
......@@ -97,6 +97,7 @@ lookupJob jid (JobMap mvar) = Map.lookup jid <$> readTVarIO mvar
gcThread :: Ord jid => JobSettings -> JobMap jid w a -> IO ()
gcThread js (JobMap mvar) = go
where go = do
threadDelay (jsGcPeriod js * 1000000)
now <- getCurrentTime
candidateEntries <- Map.filter (expired now) <$> readTVarIO mvar
forM_ candidateEntries $ \je -> do
......@@ -108,7 +109,6 @@ gcThread js (JobMap mvar) = go
case mrunningjob of
Nothing -> return ()
Just a -> killJ a
threadDelay (jsGcPeriod js * 1000000)
go
expired now jobentry = case jTimeoutAfter jobentry of
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment