[ANN] Lwt.6.0.0~alpha (direct-style)

If that turns up issues, I suppose one work-around, albeit sub-optimal, is to restore the effect of Lwt_unix.(set_default_async_method Async_none), and copiously document the need to call it if invoking anything in Lwt_process or Lwt_unix.fork and Lwt_unix.system and so forth. But the best advice is probably not to try spawning new processes in any Lwt program.

I think @raphael-proust 's answer is excellent, but I’d like to add a couple things:

  • the implementation is roughly 130 loc, some of which related to local storage, so it’s reasonable to read it all to understand how it works
  • lwt_direct is designed to be a very light addition to lwt that does as little as possible and relies on lwt as much as possible, running in the same scheduler, etc. so it doesn’t add parallelism or a new kind of future.
  • run and await are similar to domainslib’s eponymous functions: await (the desirable part) allows direct style code to wait for promises, but it needs to run in a context with an event handler, hence run.
3 Likes