guile-knots/tests/resource-pool.scm
Christopher Baines dcb56ee2c5 Tweak the resource pool
Mostly to no longer sleep in the main fiber. Now the main fiber just
spawns other fibers when it would previously block on put-operation
and these other fibers communicate back to the main resource pool
fiber when necessary.

This should mean that the resource pool is more responsive.
2025-01-09 09:34:11 +00:00

39 lines
1 KiB
Scheme

(use-modules (tests)
(fibers)
(unit-test)
(knots resource-pool))
(run-fibers-for-tests
(lambda ()
(let ((resource-pool (make-resource-pool
(lambda ()
2)
1)))
(assert-equal
(with-resource-from-pool resource-pool
res
res)
2))))
(run-fibers-for-tests
(lambda ()
(let ((resource-pool (make-resource-pool
(lambda ()
2)
1
#:add-resources-parallelism 1)))
(assert-equal
(with-resource-from-pool resource-pool
res
res)
2))))
(let* ((error-constructor
(record-constructor &resource-pool-timeout))
(err
(error-constructor 'foo)))
(assert-equal
(resource-pool-timeout-error-pool err)
'foo))
(display "resource-pool test finished successfully\n")