Page
Library
Module
Module type
Parameter
Class
Class type
Source
Moonpool_lwtSourceLwt_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
fut_of_lwt lwt_fut makes a thread-safe moonpool future that completes when lwt_fut does. This can be run from any thread.
lwt_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.
This 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.
await_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.
Exception handler for tasks that raise an uncaught exception.
lwt_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.
Is the moonpool-lwt bridge setup? This is thread safe.