Improve the implementation of checking for idle resources

This commit is contained in:
Christopher Baines 2024-08-18 09:48:08 +01:00
parent 3887435a7d
commit c2ccd81006

View file

@ -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)