test: regression test for bug

This commit is contained in:
Simon Cruanes 2023-11-07 20:00:24 -05:00
parent d2be2db0ef
commit 245bfd9b7b
2 changed files with 29 additions and 0 deletions

View file

@ -1,6 +1,7 @@
(tests (tests
(names (names
t_fib t_fib
t_ws_pool_confusion
t_bench1 t_bench1
t_fib_rec t_fib_rec
t_futs1 t_futs1

View file

@ -0,0 +1,28 @@
open Moonpool
let delay () = Thread.delay 0.001
let run ~p_main:_ ~p_sub () =
let f1 =
Fut.spawn ~on:p_sub (fun () ->
delay ();
1)
in
let f2 =
Fut.spawn ~on:p_sub (fun () ->
delay ();
2)
in
Fut.wait_block_exn f1 + Fut.wait_block_exn f2
let () =
let p_main = Ws_pool.create ~num_threads:2 () in
let p_sub = Ws_pool.create ~num_threads:10 () in
let futs = List.init 8 (fun _ -> Fut.spawn ~on:p_main (run ~p_main ~p_sub)) in
let l = List.map Fut.wait_block_exn futs in
assert (l = List.init 8 (fun _ -> 3));
print_endline "ok";
()