820
821
queue(factory: ITask<Promise<T>>): Promise<T> {
823
throw new Error('Object has been disposed');
824
}
826
>
827
>
return new Promise<T>((c, e) => {
828
>
this.outstandingPromises.push({ factory, c, e });
829
>
this.consume();
830
>
});
831
>
}
832
833
private consume(): void {
834
>
while (this.outstandingPromises.length && this.runningPromises < this.maxDegreeOfParalellism) {
async.ts
835
>
const iLimitedTask = this.outstandingPromises.shift()!;
836
>
this.runningPromises++;
837
>
838
>
const promise = iLimitedTask.factory();
839
>
promise.then(iLimitedTask.c, iLimitedTask.e);
840
>
promise.then(() => this.consumed(), () => this.consumed());
841
>
}
842
>
}
843
844
private consumed(): void {