summaryrefslogtreecommitdiff
path: root/src/Job.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Job.hs')
-rw-r--r--src/Job.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Job.hs b/src/Job.hs
index bcc7f08..25b9a73 100644
--- a/src/Job.hs
+++ b/src/Job.hs
@@ -90,6 +90,7 @@ textJobStatus = \case
data JobManager = JobManager
{ jmSemaphore :: TVar Int
+ , jmDataDir :: FilePath
, jmJobs :: TVar (Map JobId (TVar (JobStatus JobOutput)))
, jmNextTaskId :: TVar TaskId
, jmNextTask :: TVar (Maybe TaskId)
@@ -99,8 +100,8 @@ data JobManager = JobManager
newtype TaskId = TaskId Int
deriving (Eq, Ord)
-newJobManager :: Int -> IO JobManager
-newJobManager queueLen = do
+newJobManager :: FilePath -> Int -> IO JobManager
+newJobManager jmDataDir queueLen = do
jmSemaphore <- newTVarIO queueLen
jmJobs <- newTVarIO M.empty
jmNextTaskId <- newTVarIO (TaskId 0)
@@ -146,8 +147,8 @@ runManagedJob JobManager {..} tid job = bracket acquire release (\_ -> job)
writeTVar jmNextTask (Just tid')
-runJobs :: JobManager -> FilePath -> Commit -> [ Job ] -> IO [ ( Job, TVar (JobStatus JobOutput) ) ]
-runJobs mngr@JobManager {..} dir commit jobs = do
+runJobs :: JobManager -> Commit -> [ Job ] -> IO [ ( Job, TVar (JobStatus JobOutput) ) ]
+runJobs mngr@JobManager {..} commit jobs = do
treeId <- readTreeId commit
results <- atomically $ do
forM jobs $ \job -> do
@@ -177,7 +178,7 @@ runJobs mngr@JobManager {..} dir commit jobs = do
uses <- waitForUsedArtifacts job results outVar
runManagedJob mngr tid $ do
liftIO $ atomically $ writeTVar outVar JobRunning
- prepareJob dir commit job $ \checkoutPath jdir -> do
+ prepareJob jmDataDir commit job $ \checkoutPath jdir -> do
updateStatusFile (jdir </> "status") outVar
JobDone <$> runJob job uses checkoutPath jdir