compat 4.x

This commit is contained in:
Simon Cruanes 2023-07-09 22:04:18 -04:00
parent 68e744290b
commit 427c462778
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
3 changed files with 16 additions and 2 deletions

View file

@ -69,6 +69,8 @@ let num_tasks_ (self : state) : int =
Array.iter (fun q -> n := !n + Bb_queue.size q) self.qs;
!n
[@@@ifge 5.0]
(* DLA interop *)
let prepare_for_await () : Dla_.t =
(* current state *)
@ -89,6 +91,12 @@ let prepare_for_await () : Dla_.t =
let t = { Dla_.release; await } in
t
[@@@else_]
let prepare_for_await () = { Dla_.release = ignore; await = ignore }
[@@@endif]
exception Got_task of task
type around_task = AT_pair : (t -> 'a) * (t -> 'a -> unit) -> around_task

View file

@ -33,4 +33,8 @@ let with_suspend ~(run : with_handler:bool -> task -> unit) (f : unit -> unit) :
E.try_with f () { E.effc }
[@@@ocaml.alert "+unstable"]
[@@@else_]
let with_suspend ~run:_ f = f ()
[@@@endif]

View file

@ -48,11 +48,13 @@ val suspend : suspension_handler -> unit
and a task runner function.
*)
[@@@endif]
val with_suspend :
run:(with_handler:bool -> task -> unit) -> (unit -> unit) -> unit
(** [with_suspend ~run f] runs [f()] in an environment where [suspend]
will work. If [f()] suspends with suspension handler [h],
this calls [h ~run k] where [k] is the suspension.
*)
[@@@endif]
This will not do anything on OCaml 4.x.
*)