diff options
author | Christopher Baines <mail@cbaines.net> | 2024-08-18 09:48:08 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2024-08-18 12:48:29 +0100 |
commit | c2ccd8100600d558342d1ad6546cc43a63237c33 (patch) | |
tree | 49ad36d0ec1f4a0a123d5e93bc12403767ed02ce /guix-data-service | |
parent | 3887435a7d9fa6594b1553fdb8e9d48cfa5af708 (diff) | |
download | data-service-c2ccd8100600d558342d1ad6546cc43a63237c33.tar data-service-c2ccd8100600d558342d1ad6546cc43a63237c33.tar.gz |
Improve the implementation of checking for idle resources
Diffstat (limited to 'guix-data-service')
-rw-r--r-- | guix-data-service/utils.scm | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/guix-data-service/utils.scm b/guix-data-service/utils.scm index 71426f8..393db95 100644 --- a/guix-data-service/utils.scm +++ b/guix-data-service/utils.scm @@ -160,6 +160,13 @@ (checkout-failure-count 0)) (spawn-fiber (lambda () + (when idle-seconds + (spawn-fiber + (lambda () + (while #t + (sleep idle-seconds) + (put-message channel '(check-for-idle-resources)))))) + (while #t (with-exception-handler (lambda (exn) @@ -174,15 +181,7 @@ (waiters '()) (resources-last-used '())) - (match (if idle-seconds - (perform-operation - (choice-operation - (get-operation channel) - (wrap-operation - ;; TODO Do something smarter - (sleep-operation 10) - (const '(check-for-idle-resources))))) - (get-message channel)) + (match (get-message channel) (('checkout reply) (if (null? available) (if (= (length resources) max-size) |