mirror of
https://github.com/ocaml-multicore/eio.git
synced 2025-12-07 00:01:52 -05:00
Instead of requiring every cancellable operation to pass a `~sw` argument, give each fibre a default switch and use that. It's too easy to forget to make something cancellable and clutters up the code.
20 lines
318 B
OCaml
20 lines
318 B
OCaml
open EffectHandlers.Deep
|
|
|
|
type state = {
|
|
tid : Ctf.id;
|
|
mutable switch : Eio.Std.Switch.t;
|
|
}
|
|
|
|
type 'a t = {
|
|
fibre : state;
|
|
k : ('a, [`Exit_scheduler]) continuation;
|
|
}
|
|
|
|
let continue t v =
|
|
Ctf.note_switch t.fibre.tid;
|
|
continue t.k v
|
|
|
|
let discontinue t ex =
|
|
Ctf.note_switch t.fibre.tid;
|
|
discontinue t.k ex
|