Fix queue limit off-by-one
This commit is contained in:
parent
2cdec2aa2f
commit
a9aba8b06b
1 changed files with 2 additions and 2 deletions
|
@ -12,7 +12,7 @@ class Queue {
|
||||||
enqueue(task) {
|
enqueue(task) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.tasks.push({ task, resolve, reject });
|
this.tasks.push({ task, resolve, reject });
|
||||||
if (this.ongoing <= this.limit) {
|
if (this.ongoing < this.limit) {
|
||||||
this.process();
|
this.process();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -29,7 +29,7 @@ class Queue {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ongoing--;
|
this.ongoing--;
|
||||||
while (this.ongoing <= this.limit && this.tasks.length > 0) {
|
while (this.ongoing < this.limit && this.tasks.length > 0) {
|
||||||
this.process();
|
this.process();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue