Permalink
Browse files

Only call callImmediates once per batch

Reviewed By: AaaChiuuu

Differential Revision: D5163897

fbshipit-source-id: bcff70c4a6a6329b9ae771d9cad14876e3a40250
  • Loading branch information...
javache authored and facebook-github-bot committed Jun 2, 2017
1 parent c57d7ea commit 07ee2fb90a816205ec1b154c03dd9adf8f6f1941
Showing with 10 additions and 8 deletions.
  1. +4 −5 Libraries/BatchedBridge/MessageQueue.js
  2. +6 −3 Libraries/Core/Timers/JSTimersExecution.js
@@ -99,7 +99,6 @@ class MessageQueue {
callFunctionReturnFlushedQueue(module: string, method: string, args: Array<any>) {
this.__guard(() => {
this.__callFunction(module, method, args);
this.__callImmediates();
});
return this.flushedQueue();
@@ -109,7 +108,6 @@ class MessageQueue {
let result;
this.__guard(() => {
result = this.__callFunction(module, method, args);
this.__callImmediates();
});
return [result, this.flushedQueue()];
@@ -118,14 +116,15 @@ class MessageQueue {
invokeCallbackAndReturnFlushedQueue(cbID: number, args: Array<any>) {
this.__guard(() => {
this.__invokeCallback(cbID, args);
this.__callImmediates();
});
return this.flushedQueue();
}
flushedQueue() {
this.__callImmediates();
this.__guard(() => {
this.__callImmediates();
});
const queue = this._queue;
this._queue = [[], [], [], this._callID];
@@ -220,7 +219,7 @@ class MessageQueue {
__callImmediates() {
Systrace.beginEvent('JSTimersExecution.callImmediates()');
this.__guard(() => JSTimersExecution.callImmediates());
JSTimersExecution.callImmediates();
Systrace.endEvent();
}
@@ -187,7 +187,9 @@ const JSTimersExecution = {
* more immediates are queued up (can be used as a condition a while loop).
*/
callImmediatesPass() {
Systrace.beginEvent('JSTimersExecution.callImmediatesPass()');
if (__DEV__) {
Systrace.beginEvent('JSTimersExecution.callImmediatesPass()');
}
// The main reason to extract a single pass is so that we can track
// in the system trace
@@ -202,8 +204,9 @@ const JSTimersExecution = {
}
}
Systrace.endEvent();
if (__DEV__) {
Systrace.endEvent();
}
return JSTimersExecution.immediates.length > 0;
},

0 comments on commit 07ee2fb

Please sign in to comment.