Improve queuing strategies in the app

This commit is contained in:
Scott Nonnenberg 2019-07-09 11:46:48 -07:00
parent 7b645011c2
commit cb2c691667
6 changed files with 85 additions and 131 deletions

View file

@ -736,23 +736,14 @@
},
queueJob(callback) {
const previous = this.pending || Promise.resolve();
this.jobQueue = this.jobQueue || new window.PQueue({ concurrency: 1 });
const taskWithTimeout = textsecure.createTaskWithTimeout(
callback,
`conversation ${this.idForLogging()}`
);
this.pending = previous.then(taskWithTimeout, taskWithTimeout);
const current = this.pending;
current.then(() => {
if (this.pending === current) {
delete this.pending;
}
});
return current;
return this.jobQueue.add(taskWithTimeout);
},
getRecipients() {