diff options
author | Christopher Baines <mail@cbaines.net> | 2025-02-10 11:55:17 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2025-02-10 11:55:17 +0000 |
commit | 68968ce66d2900dceaaba9e4a62867c8a232ff7b (patch) | |
tree | cd8625d9bdd9b17b6be9dfb833a1ad2da145e489 /guix-build-coordinator | |
parent | 79697f5a860a57a25be50df7b0845850afae3619 (diff) | |
download | build-coordinator-68968ce66d2900dceaaba9e4a62867c8a232ff7b.tar build-coordinator-68968ce66d2900dceaaba9e4a62867c8a232ff7b.tar.gz |
Actually reset the state of the reusable-condition
Also export reusable-condition?
Diffstat (limited to 'guix-build-coordinator')
-rw-r--r-- | guix-build-coordinator/utils/fibers.scm | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/guix-build-coordinator/utils/fibers.scm b/guix-build-coordinator/utils/fibers.scm index c34ef69..776c470 100644 --- a/guix-build-coordinator/utils/fibers.scm +++ b/guix-build-coordinator/utils/fibers.scm @@ -22,6 +22,7 @@ make-discrete-priority-queueing-channels make-reusable-condition + reusable-condition? signal-reusable-condition! reusable-condition-wait) #:replace (retry-on-error)) @@ -128,13 +129,18 @@ (define* (reusable-condition-wait reusable-condition #:key (timeout #f)) - (if (atomic-box-ref (reusable-condition-atomic-box reusable-condition)) - #t - ;; Not great as this is subject to race conditions, but it should - ;; roughly work - (if timeout - (perform-operation - (choice-operation - (get-operation (reusable-condition-channel reusable-condition)) - (sleep-operation timeout))) - (get-message (reusable-condition-channel reusable-condition))))) + (let ((val + (if (atomic-box-ref (reusable-condition-atomic-box reusable-condition)) + #t + ;; Not great as this is subject to race conditions, but it should + ;; roughly work + (if timeout + (perform-operation + (choice-operation + (get-operation (reusable-condition-channel reusable-condition)) + (wrap-operation (sleep-operation timeout) + (const #f)))) + (get-message (reusable-condition-channel reusable-condition)))))) + (atomic-box-set! (reusable-condition-atomic-box reusable-condition) + #f) + val)) |