[wg-parallel] About Lwt and Async

Jeremie Dimino jdimino at janestreet.com
Wed May 1 08:13:06 BST 2013

I had thought about that a bit.  So yes it is technically possible,
here is what would need to be done:

- write a Lwt module on top of async: doable
- write an engine for lwt.unix using the async scheduler: should be trivial
- adapt a little bit Lwt_unix for signal handling
- add a few things to async (immediate bind, local storage)

Though in the end there the result will be less efficient than the
default lwt, for instance because there is one more level of boxing
for each thread due to the Or_error.t.

Also just that will provide very basic integration, for example if a
part of your program uses async and another part uses lwt you cannot
pass file descriptors from one to another since the type will still be
different.  With more work it would be possible to get more
integration and to use async's file descriptors in Lwt_unix for

Anyway I think the first part shouldn't be too much work, it could be
an intern project.

On Wed, May 1, 2013 at 1:48 AM, Yaron Minsky <yminsky at janestreet.com> wrote:
> Jeremie, I have another thought about trying to bring Lwt and Async
> together: knowing the two engines well as you do, do you think it
> makes any technical sense to basically bolt an Lwt skin on top of
> Async?  i.e., create an alternate version of the Lwt module where 'a
> Lwt.t = 'a Or_exn.t Deferred.t, so as to let one share the core
> scheduler.  This could allow code written to Lwt to run on top of
> Async's engine.
> I suspect it would be quite a large effort, and perhaps the Lwt
> community would have no interest in using the result of it, so I'm not
> saying it's worth doing.  I'm just wondering if you think it's a
> technically feasible project.

More information about the wg-parallel mailing list