eio/lib_eunix/suspended.ml
Thomas Leonard ed2382bed5 Implicit cancellation
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.
2021-11-08 13:27:51 +00:00

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