diff --git a/test/dune b/test/dune index 50a73317..a843ee36 100644 --- a/test/dune +++ b/test/dune @@ -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)) diff --git a/test/t_resource.ml b/test/t_resource.ml new file mode 100644 index 00000000..2cdd7728 --- /dev/null +++ b/test/t_resource.ml @@ -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)