3 (defvar *mutex* (sb-thread:make-mutex))
4 (defvar *waitq* (sb-thread:make-waitqueue))
7 (defgeneric process-job-in-system (job-system job))
8 (defgeneric shutdown-system (job-system))
10 (defun start-processor-thread ()
11 (format t "Starting processor in ~(~A~) mode~%" *job-system*)
15 (sb-thread:make-thread
21 ((job (find :queued *all-job* :key #'job-status)))
24 ; We just wait here until the processor is released, which is usually done
25 ; when a project is refreshed.
26 (sb-thread:with-mutex (*mutex*)
27 (sb-thread:condition-wait *waitq* *mutex*))))))
31 (format t "Shutting down processor thread~%")
33 (awaken-processor-thread)
34 (sb-thread:join-thread processor-thread)
35 (shutdown-system *job-system*))
36 sb-ext:*exit-hooks*)))
38 (defun awaken-processor-thread ()
39 (sb-thread:with-mutex (*mutex*)
40 (sb-thread:condition-broadcast *waitq*)))
42 (defun process-job (job)
43 (set-job-status job :in-progress)
44 (git (job-project job) "checkout" (job-sha job))
45 (if (not (probe-file (format nil "~A.candle" (project-dir (job-project job)))))
46 (set-job-status job :no-candle-file)
47 (multiple-value-bind (result log) (process-job-in-system *job-system* job)
48 (set-job-status job (if result :succeeded :failed))
49 (set-job-log job log))))