mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
compat
This commit is contained in:
parent
42d16465c3
commit
a2ea24551b
1 changed files with 10 additions and 10 deletions
|
|
@ -10,6 +10,16 @@ type suspension_handler = {
|
||||||
}
|
}
|
||||||
[@@unboxed]
|
[@@unboxed]
|
||||||
|
|
||||||
|
type with_suspend_handler =
|
||||||
|
| WSH : {
|
||||||
|
on_suspend: unit -> 'state;
|
||||||
|
(** on_suspend called when [f()] suspends itself. *)
|
||||||
|
run: 'state -> task -> unit; (** run used to schedule new tasks *)
|
||||||
|
resume: 'state -> suspension -> unit Exn_bt.result -> unit;
|
||||||
|
(** resume run the suspension. Must be called exactly once. *)
|
||||||
|
}
|
||||||
|
-> with_suspend_handler
|
||||||
|
|
||||||
[@@@ifge 5.0]
|
[@@@ifge 5.0]
|
||||||
[@@@ocaml.alert "-unstable"]
|
[@@@ocaml.alert "-unstable"]
|
||||||
|
|
||||||
|
|
@ -22,16 +32,6 @@ type _ Effect.t +=
|
||||||
let[@inline] yield () = Effect.perform Yield
|
let[@inline] yield () = Effect.perform Yield
|
||||||
let[@inline] suspend h = Effect.perform (Suspend h)
|
let[@inline] suspend h = Effect.perform (Suspend h)
|
||||||
|
|
||||||
type with_suspend_handler =
|
|
||||||
| WSH : {
|
|
||||||
on_suspend: unit -> 'state;
|
|
||||||
(** on_suspend called when [f()] suspends itself. *)
|
|
||||||
run: 'state -> task -> unit; (** run used to schedule new tasks *)
|
|
||||||
resume: 'state -> suspension -> unit Exn_bt.result -> unit;
|
|
||||||
(** resume run the suspension. Must be called exactly once. *)
|
|
||||||
}
|
|
||||||
-> with_suspend_handler
|
|
||||||
|
|
||||||
let with_suspend (WSH { on_suspend; run; resume }) (f : unit -> unit) : unit =
|
let with_suspend (WSH { on_suspend; run; resume }) (f : unit -> unit) : unit =
|
||||||
let module E = Effect.Deep in
|
let module E = Effect.Deep in
|
||||||
(* effect handler *)
|
(* effect handler *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue