Skip to content

Commit

Permalink
Fix with Eio
Browse files Browse the repository at this point in the history
  • Loading branch information
patricoferris committed Sep 14, 2023
1 parent ce0b6b4 commit d5915f6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
12 changes: 6 additions & 6 deletions example/burn.ml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
open Eio

let woops_sleepy ~clock =
Private.Ctf.set_name "sleeper";
Private.Tracing.set_name "sleeper";
Switch.run ~name:"sleeper" @@ fun sw ->
Fiber.fork ~sw (fun () ->
Private.Ctf.set_name "unix sleeper";
Private.Tracing.set_name "unix sleeper";
(* Woops! Wrong sleep function, we blocked the fiber *)
traceln "Woops! Blocked by Unix.sleepf";
Unix.sleepf 5.;
Time.sleep clock 10.)

let spawn ~clock min max =
Private.Ctf.set_name (Fmt.str "spawn %d %d" min max);
Private.Tracing.set_name (Fmt.str "spawn %d %d" min max);
(* Some GC action *)
for _i = 0 to 100 do
ignore (Sys.opaque_identity @@ Array.init 1000000 float_of_int)
done;
Switch.run @@ fun sw ->
for i = min to max do
Fiber.fork ~sw (fun () ->
Private.Ctf.set_name (Fmt.str "worker>%d" i);
Private.Tracing.set_name (Fmt.str "worker>%d" i);
for i = 0 to max do
(* Some more GC action *)
for _i = 0 to 100 do
Expand All @@ -39,7 +39,7 @@ let main clock =
Switch.run ~name:"main" @@ fun sw ->
(* A long running task *)
Fiber.fork ~sw (fun () ->
Private.Ctf.set_name "waiter";
Private.Tracing.set_name "waiter";
traceln "stuck waiting :(";
Promise.await p;
traceln "Done");
Expand All @@ -53,6 +53,6 @@ let main clock =

let () =
Eio_main.run @@ fun env ->
Ctf.with_tracing @@ fun () ->
Tracing.with_tracing @@ fun () ->
let clock = Stdenv.clock env in
main clock
2 changes: 1 addition & 1 deletion example/burn_domains.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let main dom_mgr clock =

let () =
Eio_main.run @@ fun env ->
Ctf.with_tracing @@ fun () ->
Tracing.with_tracing @@ fun () ->
let clock = Stdenv.clock env in
let dom_mgr = Stdenv.domain_mgr env in
main dom_mgr clock
2 changes: 1 addition & 1 deletion example/deadlock.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let fork wait =
Switch.run @@ fun sw ->
Fiber.fork ~sw (fun () ->
(* Also add a really big label to test the handling of that in CTF. *)
Eio.Private.Ctf.log (String.make 5000 'e');
Eio.Private.Tracing.log (String.make 5000 'e');
Promise.await wait)

let main () =
Expand Down
2 changes: 1 addition & 1 deletion example/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ let main clock =

let () =
Eio_main.run @@ fun env ->
Ctf.with_tracing @@ fun () ->
Tracing.with_tracing @@ fun () ->
let clock = Stdenv.clock env in
main clock
5 changes: 5 additions & 0 deletions meio.opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ depends: [
"nottui"
"cmdliner"
"hdr_histogram"
"eio_main" {with-test}
"odoc" {with-doc}
]
build: [
Expand All @@ -35,3 +36,7 @@ build: [
["dune" "install" "-p" name "--create-install-files" name]
]
dev-repo: "git+https://github.com/patricoferris/eio-console.git"
pin-depends:[
[ "eio.dev" "git+https://github.com/patricoferris/eio#dbd52c66a6e463720b48cb835d01f0e5c7c0b170"]
[ "eio_main.dev" "git+https://github.com/patricoferris/eio#dbd52c66a6e463720b48cb835d01f0e5c7c0b170" ]
]
2 changes: 1 addition & 1 deletion src/lib/task_tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let invalidate t = List.iter Lwd.invalidate t.waiters

let add t (task : Task.t) =
match task.kind with
| Meio_runtime_events.Cancellation_context _ | Meio_runtime_events.Task -> (
| Meio_runtime_events.Cancellation_context _ -> (
match Hashtbl.find_opt t.by_id (Task.Id.extern_of_int task.parent_id) with
| None ->
Logs.warn (fun f ->
Expand Down

0 comments on commit d5915f6

Please sign in to comment.