test for proper resource handling in Pool.shutdown

This commit is contained in:
Simon Cruanes 2023-08-13 22:23:53 -04:00
parent 7b0e7de94d
commit 6c4d2cbc79
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 14 additions and 1 deletions

View file

@ -1,5 +1,5 @@
(tests
(names t_fib t_bench1 t_fib_rec t_futs1 t_tree_futs t_props t_chan_train)
(names t_fib t_bench1 t_fib_rec t_futs1 t_tree_futs t_props t_chan_train t_resource)
(libraries moonpool qcheck-core qcheck-core.runner
;tracy-client.trace
trace))

13
test/t_resource.ml Normal file
View file

@ -0,0 +1,13 @@
open! Moonpool
let ( let@ ) = ( @@ )
(* test proper resource handling *)
let () =
let a = Atomic.make 0 in
for _i = 1 to 1_000 do
(* allocate a new pool at each iteration *)
let@ p = Pool.with_ ~min:4 () in
Pool.run_wait_block p (fun () -> Atomic.incr a)
done;
assert (Atomic.get a = 1_000)