mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-09 04:35:33 -05:00
compat 4.x
This commit is contained in:
parent
68e744290b
commit
427c462778
3 changed files with 16 additions and 2 deletions
|
|
@ -69,6 +69,8 @@ let num_tasks_ (self : state) : int =
|
||||||
Array.iter (fun q -> n := !n + Bb_queue.size q) self.qs;
|
Array.iter (fun q -> n := !n + Bb_queue.size q) self.qs;
|
||||||
!n
|
!n
|
||||||
|
|
||||||
|
[@@@ifge 5.0]
|
||||||
|
|
||||||
(* DLA interop *)
|
(* DLA interop *)
|
||||||
let prepare_for_await () : Dla_.t =
|
let prepare_for_await () : Dla_.t =
|
||||||
(* current state *)
|
(* current state *)
|
||||||
|
|
@ -89,6 +91,12 @@ let prepare_for_await () : Dla_.t =
|
||||||
let t = { Dla_.release; await } in
|
let t = { Dla_.release; await } in
|
||||||
t
|
t
|
||||||
|
|
||||||
|
[@@@else_]
|
||||||
|
|
||||||
|
let prepare_for_await () = { Dla_.release = ignore; await = ignore }
|
||||||
|
|
||||||
|
[@@@endif]
|
||||||
|
|
||||||
exception Got_task of task
|
exception Got_task of task
|
||||||
|
|
||||||
type around_task = AT_pair : (t -> 'a) * (t -> 'a -> unit) -> around_task
|
type around_task = AT_pair : (t -> 'a) * (t -> 'a -> unit) -> around_task
|
||||||
|
|
|
||||||
|
|
@ -33,4 +33,8 @@ let with_suspend ~(run : with_handler:bool -> task -> unit) (f : unit -> unit) :
|
||||||
E.try_with f () { E.effc }
|
E.try_with f () { E.effc }
|
||||||
|
|
||||||
[@@@ocaml.alert "+unstable"]
|
[@@@ocaml.alert "+unstable"]
|
||||||
|
[@@@else_]
|
||||||
|
|
||||||
|
let with_suspend ~run:_ f = f ()
|
||||||
|
|
||||||
[@@@endif]
|
[@@@endif]
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,13 @@ val suspend : suspension_handler -> unit
|
||||||
and a task runner function.
|
and a task runner function.
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
[@@@endif]
|
||||||
|
|
||||||
val with_suspend :
|
val with_suspend :
|
||||||
run:(with_handler:bool -> task -> unit) -> (unit -> unit) -> unit
|
run:(with_handler:bool -> task -> unit) -> (unit -> unit) -> unit
|
||||||
(** [with_suspend ~run f] runs [f()] in an environment where [suspend]
|
(** [with_suspend ~run f] runs [f()] in an environment where [suspend]
|
||||||
will work. If [f()] suspends with suspension handler [h],
|
will work. If [f()] suspends with suspension handler [h],
|
||||||
this calls [h ~run k] where [k] is the suspension.
|
this calls [h ~run k] where [k] is the suspension.
|
||||||
*)
|
|
||||||
|
|
||||||
[@@@endif]
|
This will not do anything on OCaml 4.x.
|
||||||
|
*)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue