mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
make applyCommands asynchronous
This commit is contained in:
parent
a7291a69bd
commit
332279d554
@ -337,10 +337,12 @@ Engine.prototype = {
|
||||
// Note that we need to need to apply client changes to the
|
||||
// current tree, not the saved snapshot
|
||||
|
||||
localJson.applyCommands(clientChanges);
|
||||
localJson.applyCommands.async(localJson, self.cb, clientChanges);
|
||||
yield;
|
||||
this._snapshot.data = localJson.data;
|
||||
this._snapshot.version = server.maxVersion;
|
||||
this._store.applyCommands(clientChanges);
|
||||
this._store.applyCommands.async(this._store, self.cb, clientChanges);
|
||||
yield;
|
||||
newSnapshot = this._store.wrap();
|
||||
|
||||
this._core.detectUpdates(self.cb, this._snapshot.data, newSnapshot);
|
||||
@ -570,7 +572,8 @@ Engine.prototype = {
|
||||
}
|
||||
|
||||
for (var i = 0; i < deltas.length; i++) {
|
||||
snap.applyCommands(deltas[i]);
|
||||
snap.applyCommands.async(snap, self.cb, deltas[i]);
|
||||
yield;
|
||||
}
|
||||
|
||||
ret.status = 0;
|
||||
|
@ -57,6 +57,7 @@ function Store() {
|
||||
}
|
||||
Store.prototype = {
|
||||
_logName: "Store",
|
||||
_yieldDuringApply: true,
|
||||
|
||||
__json: null,
|
||||
get _json() {
|
||||
@ -71,7 +72,16 @@ Store.prototype = {
|
||||
},
|
||||
|
||||
applyCommands: function Store_applyCommands(commandList) {
|
||||
let self = yield;
|
||||
|
||||
if (this._yieldDuringApply)
|
||||
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
|
||||
for (var i = 0; i < commandList.length; i++) {
|
||||
if (this._yieldDuringApply) {
|
||||
timer.initWithCallback(listener, 0, timer.TYPE_ONE_SHOT);
|
||||
yield; // Yield to main loop
|
||||
}
|
||||
var command = commandList[i];
|
||||
this._log.debug("Processing command: " + this._json.encode(command));
|
||||
switch (command["action"]) {
|
||||
@ -89,6 +99,7 @@ Store.prototype = {
|
||||
break;
|
||||
}
|
||||
}
|
||||
self.done();
|
||||
},
|
||||
|
||||
// override these in derived objects
|
||||
|
Loading…
Reference in New Issue
Block a user