Improve resource pool performance when there are lots of waiters

This commit is contained in:
Christopher Baines 2025-02-04 12:52:12 +00:00
parent aadbee0d0e
commit a11cd24e57
2 changed files with 221 additions and 138 deletions

View file

@ -105,15 +105,41 @@
(error "collision detected")))
(new-number))
1)))
(fibers-for-each
(fibers-batch-for-each
(lambda _
(with-resource-from-pool
resource-pool res
(let ((start-val counter))
(sleep 0.05)
(if (= start-val counter)
(set! counter (+ 1 counter))
(error "collision detected")))))
resource-pool res
(let ((start-val counter))
(sleep 0.05)
(if (= start-val counter)
(set! counter (+ 1 counter))
(error "collision detected")))))
20
(iota 50)))))
(run-fibers-for-tests
(lambda ()
(let* ((counter 0)
(resource-pool (make-resource-pool
(lambda ()
(let ((start-val counter))
(sleep 0.05)
(if (= start-val counter)
(set! counter (+ 1 counter))
(error "collision detected")))
(new-number))
1
#:reply-timeout #f)))
(fibers-batch-for-each
(lambda _
(with-resource-from-pool
resource-pool res
(let ((start-val counter))
(sleep 0.05)
(if (= start-val counter)
(set! counter (+ 1 counter))
(error "collision detected")))))
20
(iota 50)))))
(display "resource-pool test finished successfully\n")