From a11cd24e57ad334c26700691dca0164f410cc392 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 4 Feb 2025 12:52:12 +0000 Subject: Improve resource pool performance when there are lots of waiters --- tests/resource-pool.scm | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/resource-pool.scm b/tests/resource-pool.scm index 50dadbd..cf108de 100644 --- a/tests/resource-pool.scm +++ b/tests/resource-pool.scm @@ -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"))))) + 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"))))) + 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") -- cgit v1.2.3