kriskowal/q-comm — Issue #4: Understanding q-comm: why the busy loop?
Author: johnjbarton
Created: 2012-02-03 19:42:12+00:00
State: open

My first q-comm call was an infinite loop. As far as I can tell, my 'invoke" is calling me and I am calling it. Of course it does not fail on JS stack overflow because of the postMessage.

In trying to sort this out I trying stepping through the /2.iframe example. I kept hitting nextTick so I added logging:
nextTick = function (task) {
console.log("nextTick post to port2");
tail = tail.next = {task: task};
channel.port2.postMessage();
};
To my surprise nextTick seems to be called as fast as the CPU can run. The example does work, but I don't understand why the busy loop is needed. It will make finding my problem even more difficult.

q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
2q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
3q.js:61nextTick post to port2
index.html:17index.html: Hello, Child!
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
4q.js:61nextTick post to port2
2q.js:61nextTick post to port2
2q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
3q.js:61nextTick post to port2
2q.js:61nextTick post to port2
index.html:17index.html: Hello, Parent!
q.js:61nextTick post to port2
3q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
2q.js:61nextTick post to port2
iframe.html:13iframe.html: Hello, Parent!
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
2q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
2q.js:61nextTick post to port2
index.html:26index.html: Hi
q.js:61nextTick post to port2
2q.js:61nextTick post to port2
2q.js:61nextTick post to port2
q.js:61nextTick post to port2
2q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
2q.js:61nextTick post to port2
2q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
2q.js:61nextTick post to port2
2q.js:61nextTick post to port2
iframe.html:22iframe.html: Hi
q.js:61nextTick post to port2
q.js:61nextTick post to port2
2q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
2q.js:61nextTick post to port2
2q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
q.js:61nextTick post to port2
2q.js:61nextTick post to port2