mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-10 13:14:05 -05:00
21 lines
465 B
OCaml
21 lines
465 B
OCaml
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);
|
|
()
|