On 2/3/14 12:10 PM, Anne van Kesteren wrote:
Promise.jsm cannot be pure JS because JS doesn't have an event loop of itself.
Promise.jsm basically uses a JS-implemented nsIRunnable to the event loop that then makes it process its entire pending list of callbacks. So you only have one call from C++ to JS (though it's a nice slow call, just like the call to Services.tm.currentThread.dispatch to set up the runnable is nice and slow), and then you're running pure JS.
As always, "slow" needs to be quantified. Services.tm.currentThread.dispatch is probably on the order of 2000-5000 instructions or so before you land in the C++ code that actually does the work. Since it presumably only happens once every so often, that's not too terrible...
-Boris _______________________________________________ dev-platform mailing list [email protected] https://lists.mozilla.org/listinfo/dev-platform

