Skip to content

Commit b006be7

Browse files
committed
Add run_main
This is convenient for use with MDX, which does some magic when you refer to `Lwt`, which can break things.
1 parent 695eb75 commit b006be7

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lib/picos_lwt.unix/picos_lwt_unix.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,5 @@ let run ?(forbid = false) main =
8282
let fiber = Fiber.create ~forbid computation in
8383
let main _ = Computation.capture computation main () in
8484
run_fiber fiber main |> Lwt.map @@ fun () -> Computation.peek_exn computation
85+
86+
let run_main ?forbid main = Lwt_main.run (run ?forbid main)

lib/picos_lwt.unix/picos_lwt_unix.mli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ val run : ?forbid:bool -> (unit -> 'a) -> 'a Lwt.t
1717
1818
The optional [forbid] argument defaults to [false] and determines whether
1919
propagation of cancelation is initially allowed. *)
20+
21+
val run_main : ?forbid:bool -> (unit -> 'a) -> 'a
22+
(** [run_main main] is equivalent to {{!run} [Lwt_main.run (run main)]}. *)

0 commit comments

Comments
 (0)