Re: Sync API for workers

Demostration by example, thanks :-)

2013/10/13 David Rajchenbach-Teller <dteller@mozilla.com>:
> On 10/13/13 6:33 PM, piranna@gmail.com wrote:
>> Don't know, I only know behavior of Python yield statement, but
>> Javascript one was developed following it and I'm 90% secure it follows
>> the same behaviour (almost all new functionalities of Javascript are
>> being borrowed from Python since seems Mozilla Javascript implementors
>> are Python ex-programmers in purpose) so yes, I believe it should work
>> this way :-)
>
> It's slightly more complex than [my undersatnding of] your original
> phrasing, but in a word, yes, it behaves essentially as in Python.
>
> e.g., using Task.js [1], with a proper (and trivial) definition of
> wait(), the following implements a polling loop that does not block the
> event loop:
>
> Tasks.spawn(function* () {
>   while (true) {
>     yield wait();
>     poll();
>   }
> });
>
> [1] http://taskjs.org/
>
> --
> David Rajchenbach-Teller, PhD
>  Performance Team, Mozilla



-- 
"Si quieres viajar alrededor del mundo y ser invitado a hablar en un
monton de sitios diferentes, simplemente escribe un sistema operativo
Unix."
– Linus Tordvals, creador del sistema operativo Linux

Received on Sunday, 13 October 2013 19:26:29 UTC