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.