-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(** Example from https://discuss.ocaml.org/t/confused-about-moonpool-cancellation/15381 *) | ||
|
||
let ( let@ ) = ( @@ ) | ||
|
||
let () = | ||
let@ () = Trace_tef.with_setup () in | ||
let@ _ = Moonpool_fib.main in | ||
|
||
(* let@ runner = Moonpool.Ws_pool.with_ () in *) | ||
let@ runner = Moonpool.Background_thread.with_ () in | ||
|
||
(* Pretend this is some long-running read loop *) | ||
for i = 1 to 10 do | ||
Printf.printf "MAIN LOOP %d\n%!" i; | ||
Moonpool_fib.check_if_cancelled (); | ||
let _ : _ Moonpool_fib.t = | ||
Moonpool_fib.spawn ~on:runner ~protect:false (fun () -> | ||
Printf.printf "RUN FIBER %d\n%!" i; | ||
Moonpool_fib.check_if_cancelled (); | ||
Format.printf "FIBER %d NOT CANCELLED YET@." i; | ||
failwith "BOOM") | ||
in | ||
Moonpool_fib.yield (); | ||
(* Thread.delay 0.2; *) | ||
(* Thread.delay 0.0001; *) | ||
() | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(executables | ||
(names discuss1) | ||
(enabled_if | ||
(>= %{ocaml_version} 5.0)) | ||
;(package moonpool) | ||
(libraries | ||
moonpool | ||
moonpool.fib | ||
trace | ||
trace-tef | ||
;tracy-client.trace | ||
)) |