Split immediate into multiple passes
Reviewed By: tadeuzagallo Differential Revision: D2663957 fb-gh-sync-id: d7f0041fc98edb46e518f684527effe2f5201240
This commit is contained in:
parent
a3d9f5ba84
commit
c8fd9f7588
|
@ -14,6 +14,7 @@ var invariant = require('invariant');
|
||||||
var keyMirror = require('keyMirror');
|
var keyMirror = require('keyMirror');
|
||||||
var performanceNow = require('performanceNow');
|
var performanceNow = require('performanceNow');
|
||||||
var warning = require('warning');
|
var warning = require('warning');
|
||||||
|
var BridgeProfiling = require('BridgeProfiling');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JS implementation of timer functions. Must be completely driven by an
|
* JS implementation of timer functions. Must be completely driven by an
|
||||||
|
@ -107,15 +108,36 @@ var JSTimersExecution = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs a single pass over the enqueued immediates. Returns whether
|
||||||
|
* more immediates are queued up (can be used as a condition a while loop).
|
||||||
|
*/
|
||||||
|
callImmediatesPass: function() {
|
||||||
|
BridgeProfiling.profile('JSTimersExecution.callImmediatesPass()');
|
||||||
|
|
||||||
|
// The main reason to extract a single pass is so that we can track
|
||||||
|
// in the system trace
|
||||||
|
if (JSTimersExecution.immediates.length > 0) {
|
||||||
|
var passImmediates = JSTimersExecution.immediates.slice();
|
||||||
|
JSTimersExecution.immediates = [];
|
||||||
|
|
||||||
|
passImmediates.forEach((timerID) => {
|
||||||
|
JSTimersExecution.callTimer(timerID);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
BridgeProfiling.profileEnd();
|
||||||
|
|
||||||
|
return JSTimersExecution.immediates.length > 0;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called after we execute any command we receive from native but
|
* This is called after we execute any command we receive from native but
|
||||||
* before we hand control back to native.
|
* before we hand control back to native.
|
||||||
*/
|
*/
|
||||||
callImmediates: function() {
|
callImmediates: function() {
|
||||||
JSTimersExecution.errors = null;
|
JSTimersExecution.errors = null;
|
||||||
while (JSTimersExecution.immediates.length !== 0) {
|
while (JSTimersExecution.callImmediatesPass()) {}
|
||||||
JSTimersExecution.callTimer(JSTimersExecution.immediates.shift());
|
|
||||||
}
|
|
||||||
if (JSTimersExecution.errors) {
|
if (JSTimersExecution.errors) {
|
||||||
JSTimersExecution.errors.forEach((error) =>
|
JSTimersExecution.errors.forEach((error) =>
|
||||||
require('JSTimers').setTimeout(() => { throw error; }, 0)
|
require('JSTimers').setTimeout(() => { throw error; }, 0)
|
||||||
|
|
Loading…
Reference in New Issue