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) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.tasks.push({ task, resolve, reject });
|
||||
if (this.ongoing <= this.limit) {
|
||||
if (this.ongoing < this.limit) {
|
||||
this.process();
|
||||
}
|
||||
});
|
||||
|
@ -29,7 +29,7 @@ class Queue {
|
|||
}
|
||||
|
||||
this.ongoing--;
|
||||
while (this.ongoing <= this.limit && this.tasks.length > 0) {
|
||||
while (this.ongoing < this.limit && this.tasks.length > 0) {
|
||||
this.process();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue