package moonpool-lwt
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=3efd095c82a37bba8c7ab6a2532aee3c445ebe1ecaed84ef3ffb560bc65e7633
sha512=e4bcab82e6638299c2d0beb1dbf204f7b43379a5387418c6edff85b9bf90c13ad1bdd8eb44b69cd421268d1bc45bcf918bcf77e1c924348211ac27d6643aac78
doc/moonpool-lwt/Moonpool_lwt/index.html
Module Moonpool_lwt
Source
Lwt_engine-based event loop for Moonpool.
In what follows, we mean by "lwt thread" the thread running 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.
Basic conversions
fut_of_lwt lwt_fut
makes a thread-safe moonpool future that completes when lwt_fut
does. This must be run from within the Lwt 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
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.
run_in_lwt f
runs f()
from within the Lwt thread and returns a thread-safe future. This can be run from anywhere.
run_in_lwt_and_await f
runs f
in the Lwt thread, and awaits its result. Must be run from inside a moonpool runner so that the await-in effect is handled.
This is similar to Moonpool.await @@ run_in_lwt f
.
Returns the runner from within which this is called. Must be run from within a fiber.
IO
Helpers on the lwt side
detach_in_runner ~runner f
runs f
in the given moonpool runner, and returns a lwt future. This must be run from within the thread running Lwt_main
.
Wrappers around Lwt_main
main_with_runner ~runner f
starts a Lwt-based event loop and runs f()
inside a fiber in runner
.
Like main_with_runner
but with a default choice of runner.