[wg-parallel] About Lwt and Async

Anil Madhavapeddy anil at recoil.org
Mon Apr 29 11:48:43 BST 2013


On 29 Apr 2013, at 11:38, Mark Shinwell <mshinwell at janestreet.com> wrote:

> On 29 April 2013 11:18, Jeremie Dimino <jdimino at janestreet.com> wrote:
>> Lwt and async also differs regarding Lwt.wait/Ivar.fill but there
>> seems to be an agreement that the async's behavior is better and it is
>> trivial to change in lwt so that shouldn't be an issue.
> 
> I might be misunderstanding something about Lwt here, but as far as I
> see it, this latter point is quite important.  I believe one of the
> most important features of Async is the fact that you cannot be
> interrupted "between binds" by some arbitrary other job---whereas I
> do not think that is the case with the Lwt semantics (as far as I know,
> the equivalent to filling an ivar could cause something else to be
> run immediately; is that correct?).

If I understand this right, Lwt exposes `wakeup` and `wakeup_later`,
and the latter defers the wakeup until the scheduler is entered again.
Therefore, `wakeup_later` is most similar to Async's model.

I'm not sure if there are other ways in Lwt to interrupt a running
thread, aside from Lwt_preemptive.  Is it sufficient to alias Lwt.wakeup
to Lwt.wakeup_later?

-anil


More information about the wg-parallel mailing list