mirror of
https://github.com/ocaml-multicore/eio.git
synced 2025-07-29 00:02:52 -04:00
Compare commits
2 Commits
d338f8bc61
...
4856fc430d
Author | SHA1 | Date | |
---|---|---|---|
|
4856fc430d | ||
|
2aaea3f48e |
@ -23,7 +23,7 @@ let run_client sock =
|
|||||||
)
|
)
|
||||||
|
|
||||||
let time name service =
|
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 client_sock, server_sock = Eio_unix.Net.socketpair_stream ~sw () in
|
||||||
let t0 = Unix.gettimeofday () in
|
let t0 = Unix.gettimeofday () in
|
||||||
Fiber.both
|
Fiber.both
|
||||||
|
@ -69,11 +69,22 @@ let fork_promise_exn ~sw f =
|
|||||||
);
|
);
|
||||||
p
|
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 =
|
let all xs =
|
||||||
Switch.run ~name:"all" @@ fun sw ->
|
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 =
|
let pair f g =
|
||||||
Switch.run ~name:"pair" @@ fun sw ->
|
Switch.run ~name:"pair" @@ fun sw ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user