Commit f7743189 authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

When enqueuing new jobs, respect job ID

When adding new jobs, don't add them at the end, but at a
position that fits with their job id. In this way, we can
build operations that require fully dequeing a job an adding
it later after some modifications.
Signed-off-by: default avatarKlaus Aehlig <>
Reviewed-by: default avatarPetr Pudlak <>
parent 155df343
......@@ -35,6 +35,7 @@ import Control.Arrow
import Control.Concurrent
import Control.Exception
import Control.Monad
import Data.Function (on)
import Data.List
import Data.Maybe
import Data.IORef
......@@ -296,7 +297,9 @@ enqueueNewJobs state jobs = do
logInfo . (++) "New jobs enqueued: " . commaJoin
$ map (show . fromJobId . qjId) jobs
let jobs' = map unreadJob jobs
modifyJobs state (onQueuedJobs (++ jobs'))
insertFn = insertBy (compare `on` fromJobId . qjId . jJob)
addJobs oldjobs = foldl (flip insertFn) oldjobs jobs'
modifyJobs state (onQueuedJobs addJobs)
scheduleSomeJobs state
-- | Pure function for removing a queued job from the job queue by
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