Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Moonpool.Suspend_
SourceSuspensions.
This is only going to work on OCaml 5.x.
NOTE: this is not stable for now.
(Private) suspending tasks using Effects.
This module is an implementation detail of Moonpool and should not be used outside of it, except by experts to implement Runner
.
A suspended computation
type suspension_handler = {
handle : run:(with_handler:bool -> task -> unit) -> suspension -> unit;
}
The handler that knows what to do with the suspended computation.
The handler is given two things:
run
function that can be used to start tasks to perform some computation.This means that a fork-join primitive, for example, can use a single call to suspend
to:
run
to start all the tasks. Typically run
is called multiple times, which is where the "fork" part comes from. Each call to run
potentially runs in parallel with the other calls. The calls must coordinate so that, once they are all done, the suspended caller is resumed with the aggregated result of the computation.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.
*)suspend h
jumps back to the nearest with_suspend
and calls h.handle
with the current continuation k
and a task runner function.