LGTM, thanks.

On Wed, Feb 5, 2014 at 2:49 PM, Klaus Aehlig <[email protected]> wrote:

> 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: Klaus Aehlig <[email protected]>
> ---
>  src/Ganeti/JQScheduler.hs | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/Ganeti/JQScheduler.hs b/src/Ganeti/JQScheduler.hs
> index cdfe982..8359605 100644
> --- a/src/Ganeti/JQScheduler.hs
> +++ b/src/Ganeti/JQScheduler.hs
> @@ -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
> --
> 1.9.0.rc1.175.g0b1dcb5
>
>

Reply via email to