diff options
author | Christopher Baines <mail@cbaines.net> | 2020-05-11 08:15:11 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-05-11 08:15:11 +0100 |
commit | c604a4c726e6dcc1fc769294c0107f8fbd266804 (patch) | |
tree | 8f4452fc3e3fb94eecb94ae4dd29d912a305d247 | |
parent | bd7e7e76803a6c9d85a392c321839f83160d20f8 (diff) | |
download | build-coordinator-c604a4c726e6dcc1fc769294c0107f8fbd266804.tar build-coordinator-c604a4c726e6dcc1fc769294c0107f8fbd266804.tar.gz |
Try more to not forget about the need to allocate builds
If an allocation is triggered while one is in progress, store the need to
allocate again in an atomic box.
-rw-r--r-- | guix-build-coordinator/coordinator.scm | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/guix-build-coordinator/coordinator.scm b/guix-build-coordinator/coordinator.scm index 40d01e6..08ee802 100644 --- a/guix-build-coordinator/coordinator.scm +++ b/guix-build-coordinator/coordinator.scm @@ -24,6 +24,7 @@ #:use-module (srfi srfi-26) #:use-module (ice-9 ftw) #:use-module (ice-9 match) + #:use-module (ice-9 atomic) #:use-module (ice-9 threads) #:use-module (ice-9 exceptions) #:use-module (gcrypt random) @@ -150,15 +151,21 @@ (define (make-build-allocator-thread build-coordinator) (define mtx (make-mutex)) (define v (make-condition-variable)) + (define allocation-needed (make-atomic-box #f)) (define (trigger-build-allocation) + (atomic-box-set! allocation-needed #t) (signal-condition-variable v)) (call-with-new-thread (lambda () (while #t (with-mutex mtx - (wait-condition-variable v mtx) + (let ((previous-allocation-needed-value + (atomic-box-swap! allocation-needed #f))) + (when (eq? #f previous-allocation-needed-value) + (wait-condition-variable v mtx) + (atomic-box-set! allocation-needed #f))) (call-with-duration-metric (build-coordinator-metrics-registry build-coordinator) "guixbuildcoordinator_allocate_builds_duration_seconds" |