From 2910e6615008febfe93a2167aa46f690b9f268dd Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 31 Jan 2025 17:55:18 +0100 Subject: Fix issue with parallel creating resource pool resources --- tests/resource-pool.scm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/resource-pool.scm b/tests/resource-pool.scm index 24a4f53..1d998ef 100644 --- a/tests/resource-pool.scm +++ b/tests/resource-pool.scm @@ -72,4 +72,27 @@ (destroy-resource-pool resource-pool)))) +(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))) + (fibers-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"))))) + (iota 50))))) + (display "resource-pool test finished successfully\n") -- cgit v1.2.3