forked from mirrors/gecko-dev
Bug 1435000 - Refactor client engine queue to use AsyncQueueCaller r=eoger
MozReview-Commit-ID: JRWHktfqGMQ --HG-- extra : rebase_source : ac39e2ff9fb1aa2bc10504aad5f018114902145e
This commit is contained in:
parent
ad9f7a1fa4
commit
eaa5aa23b5
2 changed files with 7 additions and 5 deletions
|
|
@ -163,9 +163,10 @@ class AsyncQueueCaller {
|
|||
this._queue = (async () => {
|
||||
await this._queue;
|
||||
try {
|
||||
await func();
|
||||
return await func();
|
||||
} catch (e) {
|
||||
this._log.error(e);
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ function ClientEngine(service) {
|
|||
SyncEngine.call(this, "Clients", service);
|
||||
|
||||
this.fxAccounts = fxAccounts;
|
||||
this.addClientCommandQueue = Promise.resolve();
|
||||
this.addClientCommandQueue = Async.asyncQueueCaller(this._log);
|
||||
Utils.defineLazyIDProperty(this, "localID", "services.sync.client.GUID");
|
||||
}
|
||||
ClientEngine.prototype = {
|
||||
|
|
@ -293,8 +293,7 @@ ClientEngine.prototype = {
|
|||
},
|
||||
|
||||
async _addClientCommand(clientId, command) {
|
||||
return this.addClientCommandQueue = (async () => {
|
||||
await this.addClientCommandQueue;
|
||||
this.addClientCommandQueue.enqueueCall(async () => {
|
||||
try {
|
||||
const localCommands = await this._readCommands();
|
||||
const localClientCommands = localCommands[clientId] || [];
|
||||
|
|
@ -315,7 +314,9 @@ ClientEngine.prototype = {
|
|||
this._log.error(e);
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
});
|
||||
|
||||
return this.addClientCommandQueue.promiseCallsComplete();
|
||||
},
|
||||
|
||||
async _removeClientCommands(clientId) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue