mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 11:15:38 -05:00
test: regression test for bug
This commit is contained in:
parent
d2be2db0ef
commit
245bfd9b7b
2 changed files with 29 additions and 0 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
28
test/t_ws_pool_confusion.ml
Normal file
28
test/t_ws_pool_confusion.ml
Normal 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";
|
||||||
|
()
|
||||||
Loading…
Add table
Reference in a new issue