diff --git a/src/moonpool.ml b/src/moonpool.ml index 66e59733..91885b1a 100644 --- a/src/moonpool.ml +++ b/src/moonpool.ml @@ -9,3 +9,4 @@ module Lock = Lock module Fork_join = Fork_join module Fut = Fut module Pool = Pool +module Suspend_ = Suspend_ diff --git a/src/moonpool.mli b/src/moonpool.mli index 98e8e292..b998cc69 100644 --- a/src/moonpool.mli +++ b/src/moonpool.mli @@ -77,3 +77,13 @@ module Atomic = Atomic_ This is either a shim using [ref], on pre-OCaml 5, or the standard [Atomic] module on OCaml 5. *) + +(** {2 Suspensions} *) + +module Suspend_ = Suspend_ +[@@alert unstable "this module is an implementation detail of moonpool for now"] +(** Suspensions. + + This is only going to work on OCaml 5.x. + + {b NOTE}: this is not stable for now. *) diff --git a/src/runner.ml b/src/runner.ml index 4c5b62cf..91cde5a2 100644 --- a/src/runner.ml +++ b/src/runner.ml @@ -34,6 +34,4 @@ let run_wait_block self (f : unit -> 'a) : 'a = module For_runner_implementors = struct let create ~size ~num_tasks ~shutdown ~run_async () : t = { size; num_tasks; shutdown; run_async } - - module Suspend_ = Suspend_ end diff --git a/src/runner.mli b/src/runner.mli index a2a0f10d..9c5aca45 100644 --- a/src/runner.mli +++ b/src/runner.mli @@ -64,13 +64,4 @@ module For_runner_implementors : sig {b NOTE}: the runner should support DLA and {!Suspend_} on OCaml 5.x, so that {!Fork_join} and other 5.x features work properly. *) - - module Suspend_ = Suspend_ - [@@alert - unstable "this module is an implementation detail of moonpool for now"] - (** Suspensions. - - This is only going to work on OCaml 5.x. - - {b NOTE}: this is not stable for now. *) end diff --git a/src/suspend_.mli b/src/suspend_.mli index 0bcb7b29..bc205616 100644 --- a/src/suspend_.mli +++ b/src/suspend_.mli @@ -32,6 +32,15 @@ type suspension_handler = { *) [@@@ifge 5.0] +[@@@ocaml.alert "-unstable"] + +type _ Effect.t += + | Suspend : suspension_handler -> unit Effect.t + (** The effect used to suspend the current thread and pass it, suspended, + to the handler. The handler will ensure that the suspension is resumed later + once some computation has been done. *) + +[@@@ocaml.alert "+unstable"] val suspend : suspension_handler -> unit (** [suspend h] jumps back to the nearest {!with_suspend}