Fix a bug where resources pools could empty with waiters
This commit is contained in:
parent
40b64e269b
commit
a13098494d
2 changed files with 21 additions and 0 deletions
|
|
@ -939,6 +939,10 @@
|
||||||
(eq? x resource))
|
(eq? x resource))
|
||||||
resources)))
|
resources)))
|
||||||
|
|
||||||
|
(when (and (not (q-empty? waiters))
|
||||||
|
(< (- (length resources) 1)
|
||||||
|
max-size))
|
||||||
|
(spawn-fiber-to-return-new-resource))
|
||||||
|
|
||||||
(loop (if index
|
(loop (if index
|
||||||
(remove-at-index! resources index)
|
(remove-at-index! resources index)
|
||||||
|
|
|
||||||
|
|
@ -211,4 +211,21 @@
|
||||||
|
|
||||||
(destroy-resource-pool resource-pool))))
|
(destroy-resource-pool resource-pool))))
|
||||||
|
|
||||||
|
(run-fibers-for-tests
|
||||||
|
(lambda ()
|
||||||
|
(let ((resource-pool (make-resource-pool
|
||||||
|
(const 'foo)
|
||||||
|
1
|
||||||
|
#:lifetime 1
|
||||||
|
#:destructor
|
||||||
|
(const #t))))
|
||||||
|
(for-each
|
||||||
|
(lambda _
|
||||||
|
(with-resource-from-pool resource-pool
|
||||||
|
res
|
||||||
|
res))
|
||||||
|
(iota 20))
|
||||||
|
|
||||||
|
(destroy-resource-pool resource-pool))))
|
||||||
|
|
||||||
(display "resource-pool test finished successfully\n")
|
(display "resource-pool test finished successfully\n")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue