Seems to work for me. Node v0.11.7, Windows 8

>node-11 --harmony test.js
309.6952980849892
231.88106599263847
257.15388590469956
345.1376415323466
492.82865272834897
159.6157061867416
286.41347005032003
760.6169891078025
25.959153659641743
and so on...

On Sunday, 8 September 2013 18:28:12 UTC+10, Radford Smith wrote:
>
> When I run this code, it only runs for a moment before it gets stuck 
> (you'll need Node 0.11.x with the --harmony flag for this to work):
>
> function runner(gen) {
>   runner_(gen());
> }
>
> function runner_(iterator) {
>   var delay = Math.random() * 1000;
>   setTimeout(function() {
>     iterator.next(delay);
>     runner_(iterator);
>   }, delay);
> }
>
> runner(function*() {
>   while (true) {
>     console.log(yield null);
>   }
> });
>
>
> My understanding is that the generator function should pause at the call 
> to yield and wait for another call to next() before continuing the loop. 
> However, it seems like there is some sort of deadlock going on here. Am I 
> missing something?
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to