mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
add another test
This commit is contained in:
parent
1c94c59d88
commit
b58041153a
2 changed files with 22 additions and 0 deletions
|
|
@ -11,6 +11,7 @@
|
|||
t_resource
|
||||
t_unfair
|
||||
t_ws_deque
|
||||
t_ws_wait
|
||||
t_bounded_queue)
|
||||
(libraries
|
||||
moonpool
|
||||
|
|
|
|||
21
test/t_ws_wait.ml
Normal file
21
test/t_ws_wait.ml
Normal 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);
|
||||
()
|
||||
Loading…
Add table
Reference in a new issue