Fix idle resource removal in the resource pool
This commit is contained in:
parent
a2ab770536
commit
bddc6c04ad
2 changed files with 23 additions and 8 deletions
|
@ -391,16 +391,10 @@
|
||||||
(spawn-fiber-to-destroy-resource resource))
|
(spawn-fiber-to-destroy-resource resource))
|
||||||
resources-to-destroy))
|
resources-to-destroy))
|
||||||
|
|
||||||
(loop (lset-difference eq? resources resources-to-destroy)
|
(loop resources
|
||||||
(lset-difference eq? available resources-to-destroy)
|
(lset-difference eq? available resources-to-destroy)
|
||||||
waiters
|
waiters
|
||||||
(filter-map
|
resources-last-used)))
|
||||||
(lambda (resource last-used)
|
|
||||||
(if (memq resource resources-to-destroy)
|
|
||||||
#f
|
|
||||||
last-used))
|
|
||||||
resources
|
|
||||||
resources-last-used))))
|
|
||||||
|
|
||||||
(('destroy reply)
|
(('destroy reply)
|
||||||
(if (null? resources)
|
(if (null? resources)
|
||||||
|
|
|
@ -72,6 +72,27 @@
|
||||||
|
|
||||||
(destroy-resource-pool resource-pool))))
|
(destroy-resource-pool resource-pool))))
|
||||||
|
|
||||||
|
(run-fibers-for-tests
|
||||||
|
(lambda ()
|
||||||
|
(let ((resource-pool (make-resource-pool
|
||||||
|
new-number
|
||||||
|
2
|
||||||
|
#:idle-seconds 0.5
|
||||||
|
#:destructor
|
||||||
|
(lambda (res)
|
||||||
|
#t))))
|
||||||
|
(fibers-for-each
|
||||||
|
(lambda _
|
||||||
|
(with-resource-from-pool resource-pool
|
||||||
|
res
|
||||||
|
res))
|
||||||
|
(iota 20))
|
||||||
|
|
||||||
|
(let loop ((stats (resource-pool-stats resource-pool)))
|
||||||
|
(unless (= 0 (assq-ref stats 'resources))
|
||||||
|
(sleep 0.1)
|
||||||
|
(loop (resource-pool-stats resource-pool)))))))
|
||||||
|
|
||||||
(run-fibers-for-tests
|
(run-fibers-for-tests
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let* ((counter 0)
|
(let* ((counter 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue