Skip to content

Commit

Permalink
Simplify OperationBatcher queue consumption scheduling.
Browse files Browse the repository at this point in the history
Quick follow-up to PR #9793.
  • Loading branch information
benjamn committed Jun 7, 2022
1 parent 7857eae commit d9e9dee
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/link/batch/batching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ export class OperationBatcher {
}

// The first enqueued request triggers the queue consumption after `batchInterval` milliseconds.
if (isFirstEnqueuedRequest) {
this.scheduleQueueConsumption(key);
} else if (this.batchDebounce) {
clearTimeout(this.scheduledBatchTimer);
if (isFirstEnqueuedRequest || this.batchDebounce) {
this.scheduleQueueConsumption(key);
}

Expand Down Expand Up @@ -214,6 +211,7 @@ export class OperationBatcher {
}

private scheduleQueueConsumption(key: string): void {
clearTimeout(this.scheduledBatchTimer);
this.scheduledBatchTimer = setTimeout(() => {
this.consumeQueue(key);
}, this.batchInterval);
Expand Down

0 comments on commit d9e9dee

Please sign in to comment.