Moonpool_lwtLwt_engine-based event loop for Moonpool.
In what follows, we mean by "lwt thread" the thread running lwt_main (which wraps Lwt_main.run; so, the thread where the Lwt event loop and all Lwt callbacks execute).
NOTE: this is experimental and might change in future versions.
The API has entirely changed since 0.9 , see https://github.com/c-cube/moonpool/pull/37
module Fut = Moonpool.Futval fut_of_lwt : 'a Lwt.t -> 'a Moonpool.Fut.tfut_of_lwt lwt_fut makes a thread-safe moonpool future that completes when lwt_fut does. This can be run from any thread.
val lwt_of_fut : 'a Moonpool.Fut.t -> 'a Lwt.tlwt_of_fut fut makes a lwt future that completes when fut does. This must be called from the Lwt thread, and the result must always be used only from inside the Lwt thread.
val spawn_lwt : (unit -> 'a) -> 'a Lwt.tThis spawns a task that runs in the Lwt scheduler. This function is thread safe.
Like spawn_lwt but ignores the result, like Lwt.async. This function is thread safe.
val await_lwt : 'a Lwt.t -> 'aawait_lwt fut awaits a Lwt future from inside a task running on a moonpool runner. This must be run from within a Moonpool runner so that the await-ing effect is handled, but it doesn't have to run from inside the Lwt thread.
val on_uncaught_exn : (Moonpool.Exn_bt.t -> unit) refException handler for tasks that raise an uncaught exception.
val lwt_main : (Moonpool.Runner.t -> 'a) -> 'alwt_main f sets the moonpool-lwt bridge up, runs lwt main, calls f, destroys the bridge, and return the result of f(). Only one thread should call this at a time.
on_lwt_thread () is true if the current thread is the one currently running lwt_main. This is thread safe.
val lwt_main_runner : unit -> Moonpool.Runner.t