- (sb-thread:make-thread
- (lambda ()
- (loop
- (let
- ((job (find :queued *all-job* :key #'job-status)))
- (if job
- (process-job job)
- ; We just wait here until the processor is released, which is usually done
- ; when a project is refreshed.
- (sb-thread:with-mutex (*mutex*)
- (sb-thread:condition-wait *waitq* *mutex*))))))
- :name "Processor"))
+ (format t "Starting processor in ~(~A~) mode~%" *job-system*)
+ (let*
+ ((active t)
+ (processor-thread
+ (sb-thread:make-thread
+ (lambda ()
+ (loop
+ :while active
+ :do
+ (let
+ ((job (find :queued *all-job* :key #'job-status)))
+ (if job
+ (process-job job)
+ ; We just wait here until the processor is released, which is usually done
+ ; when a project is refreshed.
+ (sb-thread:with-mutex (*mutex*)
+ (sb-thread:condition-wait *waitq* *mutex*))))))
+ :name "Processor")))
+ (push
+ (lambda ()
+ (format t "Shutting down processor thread~%")
+ (setf active nil)
+ (awaken-processor-thread)
+ (sb-thread:join-thread processor-thread)
+ (shutdown-system *job-system*))
+ sb-ext:*exit-hooks*)))