Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bench/bench_copy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let run_client sock =
)

let time name service =
Switch.run @@ fun sw ->
Switch.run ~name @@ fun sw ->
let client_sock, server_sock = Eio_unix.Net.socketpair_stream ~sw () in
let t0 = Unix.gettimeofday () in
Fiber.both
Expand Down
15 changes: 13 additions & 2 deletions lib_eio/core/fiber.ml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,22 @@ let fork_promise_exn ~sw f =
);
p

(* Like [List.iter (fork ~sw)], but runs the last one in the current fiber
for efficiency and less cluttered traces. *)
let rec forks ~sw = function
| [] -> ()
| [x] -> Switch.check sw; x ()
| x :: xs ->
fork ~sw x;
forks ~sw xs

let all xs =
Switch.run ~name:"all" @@ fun sw ->
List.iter (fork ~sw) xs
forks ~sw xs

let both f g = all [f; g]
let both f g =
Switch.run ~name:"both" @@ fun sw ->
forks ~sw [f; g]

let pair f g =
Switch.run ~name:"pair" @@ fun sw ->
Expand Down