-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce setImmediate. #13
Conversation
Thanks for digging in to this! Just gave it a quick look, but I'll look more tomorrow or Monday. |
It is a has-ified rendition of NobleJS's implementation of setImmediate. How should I accredit them? |
installPostMessageImplementation(attachTo); | ||
} | ||
else if (has('message-channel')) { | ||
installMessageChannelImplementation(attachTo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I losing it or is this function missing? Fwiw, it'd be nice if we didn't need both window.postMessage and MessageChannel. Might be worth testing window.postMessage for speed. From six months ago: https://gist.github.com/2802407
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're not losing it, but apparently I did. Somewhere that function was left behind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have some time to test postMessage vs MessageChannel in recent browsers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have our answer: http://jsperf.com/postmessage/6 http://jsperf.com/setimmediate-test/6 http://jsperf.com/postmessage-vs-settimeout
postMessage wins in recent FF, so seems like the better choice now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool. no need to add that function, then!
Good set of tests, btw. |
setImmediate(handler); | ||
clearImmediate(handler); | ||
|
||
tester.assertFalse('setImmediate is not called after clearImmediate is called', changed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, this test would pass even if handler is called in the next turn. IOW, I think this is effectively the same as the very first test case. It's actually impossible to test that handler
is never called, but it seems like it'd be good enough to put the assertion in a setTimeout, similar to the test case after this one.
👍 |
A cross-browser implementation of the new setImmediate API.