From 9568ea7370db370c963e94b4492f4bba5c9dc0a8 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 7 Nov 2023 20:42:30 -0500 Subject: [PATCH] update tests and benchs for new Fut API --- benchs/fib_rec.ml | 2 +- test/effect-based/t_many.ml | 4 +--- test/t_chan_train.ml | 2 +- test/t_tree_futs.ml | 17 +++++++---------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/benchs/fib_rec.ml b/benchs/fib_rec.ml index 571b8495..b0f1623d 100644 --- a/benchs/fib_rec.ml +++ b/benchs/fib_rec.ml @@ -12,7 +12,7 @@ let rec fib ~on x : int Fut.t = if x <= !cutoff then Fut.spawn ~on (fun () -> fib_direct x) else - let open Fut.Infix_local in + let open Fut.Infix in let+ t1 = fib ~on (x - 1) and+ t2 = fib ~on (x - 2) in t1 + t2 diff --git a/test/effect-based/t_many.ml b/test/effect-based/t_many.ml index 6a2b5918..b4a2c8da 100644 --- a/test/effect-based/t_many.ml +++ b/test/effect-based/t_many.ml @@ -19,9 +19,7 @@ let run ~pool () = 0 l) in - let futs = - List.init n_tasks (fun _ -> Fut.spawn ~on:pool task |> Fut.join ~on:pool) - in + let futs = List.init n_tasks (fun _ -> Fut.spawn ~on:pool task |> Fut.join) in let lens = List.map Fut.wait_block_exn futs in Printf.printf "awaited %d items (%d times)\n%!" (List.hd lens) n_tasks; diff --git a/test/t_chan_train.ml b/test/t_chan_train.ml index 132d5540..20645a73 100644 --- a/test/t_chan_train.ml +++ b/test/t_chan_train.ml @@ -3,7 +3,7 @@ open Moonpool (* large pool, some of our tasks below are long lived *) let pool = Ws_pool.create ~num_threads:30 () -open (val Fut.infix pool) +open Fut.Infix type event = | E_int of int diff --git a/test/t_tree_futs.ml b/test/t_tree_futs.ml index 0bc96a03..c9905eae 100644 --- a/test/t_tree_futs.ml +++ b/test/t_tree_futs.ml @@ -15,19 +15,16 @@ let rec mk_tree ~pool n : _ tree Fut.t = let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "mk-tree" in if n <= 1 then Fut.return (Leaf 1) - else - let open (val Fut.infix pool) in - let l = - Fut.spawn ~on:pool (fun () -> mk_tree ~pool (n - 1)) |> Fut.join ~on:pool - and r = - Fut.spawn ~on:pool (fun () -> mk_tree ~pool (n - 1)) |> Fut.join ~on:pool - in + else ( + let l = Fut.spawn ~on:pool (fun () -> mk_tree ~pool (n - 1)) |> Fut.join + and r = Fut.spawn ~on:pool (fun () -> mk_tree ~pool (n - 1)) |> Fut.join in Fut.return @@ Node (l, r) + ) let rec rev ~pool (t : 'a tree Fut.t) : 'a tree Fut.t = let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "rev" in - let open (val Fut.infix pool) in + let open Fut.Infix in t >>= function | Leaf n -> Fut.return (Leaf n) | Node (l, r) -> @@ -36,7 +33,7 @@ let rec rev ~pool (t : 'a tree Fut.t) : 'a tree Fut.t = let rec sum ~pool (t : int tree Fut.t) : int Fut.t = let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "sum" in - let open (val Fut.infix pool) in + let open Fut.Infix in t >>= function | Leaf n -> Fut.return n | Node (l, r) -> @@ -45,7 +42,7 @@ let rec sum ~pool (t : int tree Fut.t) : int Fut.t = let run ~pool n : (int * int) Fut.t = let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "run" in - let open (val Fut.infix pool) in + let open Fut.Infix in let t = Fut.return n >>= mk_tree ~pool in let t' = rev ~pool t in let sum_t = sum ~pool t in