From c604a4c726e6dcc1fc769294c0107f8fbd266804 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 11 May 2020 08:15:11 +0100 Subject: 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. --- guix-build-coordinator/coordinator.scm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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" -- cgit v1.2.3