add another test

This commit is contained in:
Simon Cruanes 2023-11-24 22:55:53 -05:00
parent 1c94c59d88
commit b58041153a
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 22 additions and 0 deletions

View file

@ -11,6 +11,7 @@
t_resource t_resource
t_unfair t_unfair
t_ws_deque t_ws_deque
t_ws_wait
t_bounded_queue) t_bounded_queue)
(libraries (libraries
moonpool moonpool

21
test/t_ws_wait.ml Normal file
View file

@ -0,0 +1,21 @@
open! Moonpool
let ( let@ ) = ( @@ )
let () =
let sum = Atomic.make 0 in
let n = 300_000 in
(let@ pool = Ws_pool.with_ ~num_threads:30 () in
for _i = 1 to n do
Runner.run_async pool (fun () ->
Thread.yield ();
ignore (Atomic.fetch_and_add sum 20 : int))
done;
Runner.shutdown pool);
(* make sure that shutdown didn't terminate before
all tasks were run *)
let sum = Atomic.get sum in
assert (sum = 20 * n);
()