package moonpool-lwt
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=0f3d42753c2636a6a55427af89d2574b08a29c32100f2002ae3e47f6e4d23ff1
sha512=7fa651570493ddd7c594eb46b76782610da6a6823e5178c2b20ceafe2f159649caedaac01e975428605de865d3dff9008a798090cec77c909477a86c04532709
doc/moonpool-lwt/Moonpool_lwt/index.html
Module Moonpool_lwtSource
Lwt_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
Basic conversions
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.
Helpers on the moonpool side
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.
Wrappers around Lwt_main
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.