Am Donnerstag, den 27.10.2011, 13:36 -0400 schrieb Milan Stanojević: > >> But I think we had good reasons for creating Async. As I said in my > >> blog post, the differences in error-handling and interleaving policy > >> were enough that we really felt we needed a different library. > > > > In deed this is interesting. Equeue also follows Lwt's idea not to > > interleave when possible, simply for performance reasons. You can, > > Did you mean to say "Lwt interleaves when possible"? > > For example > > let foo () = > let r = x >>= bar in > .... > r > > in Async [bar] will run only after [foo] has completed (therefore > there is no interleaving between [foo] and [bar]), while in Lwt [bar] > can run in the middle of [foo] so there is an interleaving
You probably mean the case where x has already computed a result. When developing Uq_engines, I was a bit unsure how to treat this case. In the initial version, I just disallowed this case: There was simply no way to run into it. If you wanted to create a thread that just yields a constant value, the only way was the function eps_e, which "computes" the constant in one step (i.e. it is not immediately there, but only after rescheduling). Later I allowed this case, and also added const_e, which creates a thread with an immediate result. Nevertheless, almost all code I produced uses eps_e, not const_e, because the possible interactions with state changes are easier to overlook. However, there is also const_e when speed really matters. Besides this problem, I'm unsure where the other conceptual differences are between the threading implementation. For example, Equeue has actually two schedulers: one very simple one, which is only used when no I/O and no delays need to be considered (and which is local to Uq_engines), and a heavy one when these phenomenons can occur. The simple scheduler is really unfair - the next thread at hand is executed, often leading to a cache-friendly execution flow with high locality. But it's fast. The other scheduler is absolutely fair: all resources are treated equal, and events are queued up (fifo order). It is only invoked when the simple scheduler cannot continue. So yes, there are probably differences. I am a bit surprised that Equeue (which is part of Ocamlnet, btw) is not recognized as monadic threading library, although it was definitely the first public Ocaml library exploring this idea (beginnings in 1999), and has probably the largest user code base (remember the original wink.com search service was written with it). It was "only" never been announced as monadic, and uses a different terminology because it's a threading library in the first place, and I always hoped it's easier to understand for people without Haskell background. Gerd -- ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany [email protected] Creator of GODI and camlcity.org. Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de *** Searching for new projects! Need consulting for system *** programming in Ocaml? Gerd Stolpmann can help you. ------------------------------------------------------------ -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
