File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,8 +31,11 @@ let timely_loop' ?(immediate=false) period f =
3131(* run f every period seconds; run immediately if immediate is true; stop when wait thread terminates *)
3232let timely_loop ?immediate ?(wait =Daemon. wait_exit () ) period f = Lwt. pick [ wait; timely_loop' ?immediate period f; ]
3333
34- (* cancel t1 when t2 terminates *)
35- let ensure_order t1 t2 = (t2) [% finally Lwt. wrap1 Lwt. cancel t1; ]
34+ (* cancel t1 when t2 terminates; join so that cancelling the resulting promise cancels both t1 and t2 *)
35+ let ensure_order t1 t2 =
36+ let ignore t = let % lwt _ = t in Lwt. return_unit in
37+ let % lwt () = Lwt. join [ ignore t1; (ignore t2) [% finally Lwt. wrap1 Lwt. cancel t1; ]; ] in
38+ t2
3639
3740(* wait for t to terminate, suppress any exception, and call cleanup () afterwards *)
3841let suppress_exn name cleanup t =
You can’t perform that action at this time.
0 commit comments