diff options
author | Christopher Baines <mail@cbaines.net> | 2025-01-31 17:55:18 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2025-02-02 11:29:25 +0100 |
commit | 2910e6615008febfe93a2167aa46f690b9f268dd (patch) | |
tree | 490065cf2fe627790635fcb4093bf1aa4ea1a0f3 /tests | |
parent | 61451907a90893f6442bfa7bc135aa2610178873 (diff) | |
download | knots-2910e6615008febfe93a2167aa46f690b9f268dd.tar knots-2910e6615008febfe93a2167aa46f690b9f268dd.tar.gz |
Fix issue with parallel creating resource pool resources
Diffstat (limited to 'tests')
-rw-r--r-- | tests/resource-pool.scm | 23 |
1 files changed, 23 insertions, 0 deletions
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") |