...thus avoiding the magic constants 1000000 (number of microseconds in a second) all over the place.
Signed-off-by: Klaus Aehlig <[email protected]> --- src/Ganeti/Confd/Client.hs | 2 +- src/Ganeti/JQScheduler.hs | 6 +----- src/Ganeti/Utils.hs | 5 +++++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Ganeti/Confd/Client.hs b/src/Ganeti/Confd/Client.hs index 49ab5fd..ae77090 100644 --- a/src/Ganeti/Confd/Client.hs +++ b/src/Ganeti/Confd/Client.hs @@ -82,7 +82,7 @@ query client crType cQuery = do hmac = hmacKey client jobs = map (queryOneServer semaphore answer crType cQuery hmac) dest watchdog reqAnswers = do - threadDelay $ 1000000 * C.confdClientExpireTimeout + threadDelaySeconds C.confdClientExpireTimeout _ <- swapMVar reqAnswers 0 putMVar semaphore () waitForResult reqAnswers = do diff --git a/src/Ganeti/JQScheduler.hs b/src/Ganeti/JQScheduler.hs index 8aed60e..9ec9e1a 100644 --- a/src/Ganeti/JQScheduler.hs +++ b/src/Ganeti/JQScheduler.hs @@ -121,10 +121,6 @@ onQueuedJobs = over qEnqueuedL unreadJob :: QueuedJob -> JobWithStat unreadJob job = JobWithStat {jJob=job, jStat=nullFStat, jINotify=Nothing} --- | Reload interval for polling the running jobs for updates in microseconds. -watchInterval :: Int -watchInterval = C.luxidJobqueuePollInterval * 1000000 - -- | Read a cluster parameter from the configuration, using a default if the -- configuration is not available. getConfigValue :: (Cluster -> a) -> a -> JQStatus -> IO a @@ -488,7 +484,7 @@ updateStatusAndScheduleSomeJobs qstate = do -- | Time-based watcher for updating the job queue. onTimeWatcher :: JQStatus -> IO () onTimeWatcher qstate = forever $ do - threadDelay watchInterval + threadDelaySeconds C.luxidJobqueuePollInterval logDebug "Job queue watcher timer fired" updateStatusAndScheduleSomeJobs qstate logDebug "Job queue watcher cycle finished" diff --git a/src/Ganeti/Utils.hs b/src/Ganeti/Utils.hs index 7ec9f84..57e0aa5 100644 --- a/src/Ganeti/Utils.hs +++ b/src/Ganeti/Utils.hs @@ -96,6 +96,7 @@ module Ganeti.Utils , ensurePermissions , ordNub , isSubsequenceOf + , threadDelaySeconds ) where import Control.Applicative @@ -189,6 +190,10 @@ ensureQuoted v = if not (all (\c -> isAlphaNum c || c == '.') v) then '\'':v ++ "'" else v +-- | Delay a thread for several seconds. +threadDelaySeconds :: Int -> IO () +threadDelaySeconds = threadDelay . (*) 1000000 + -- * Mathematical functions -- Simple and slow statistical functions, please replace with better -- 2.4.3.573.g4eafbef
