Improve the implementation of checking for idle resources
This commit is contained in:
parent
3887435a7d
commit
c2ccd81006
1 changed files with 8 additions and 9 deletions
|
|
@ -160,6 +160,13 @@
|
||||||
(checkout-failure-count 0))
|
(checkout-failure-count 0))
|
||||||
(spawn-fiber
|
(spawn-fiber
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
(when idle-seconds
|
||||||
|
(spawn-fiber
|
||||||
|
(lambda ()
|
||||||
|
(while #t
|
||||||
|
(sleep idle-seconds)
|
||||||
|
(put-message channel '(check-for-idle-resources))))))
|
||||||
|
|
||||||
(while #t
|
(while #t
|
||||||
(with-exception-handler
|
(with-exception-handler
|
||||||
(lambda (exn)
|
(lambda (exn)
|
||||||
|
|
@ -174,15 +181,7 @@
|
||||||
(waiters '())
|
(waiters '())
|
||||||
(resources-last-used '()))
|
(resources-last-used '()))
|
||||||
|
|
||||||
(match (if idle-seconds
|
(match (get-message channel)
|
||||||
(perform-operation
|
|
||||||
(choice-operation
|
|
||||||
(get-operation channel)
|
|
||||||
(wrap-operation
|
|
||||||
;; TODO Do something smarter
|
|
||||||
(sleep-operation 10)
|
|
||||||
(const '(check-for-idle-resources)))))
|
|
||||||
(get-message channel))
|
|
||||||
(('checkout reply)
|
(('checkout reply)
|
||||||
(if (null? available)
|
(if (null? available)
|
||||||
(if (= (length resources) max-size)
|
(if (= (length resources) max-size)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue