Skip to content

Commit

Permalink
Improve interruptAndCheck behavior (#1787)
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoecode authored Jan 23, 2025
1 parent f8dadea commit a829dfd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/langium/src/utils/promise-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export async function interruptAndCheck(token: CancellationToken): Promise<void>
if (current - lastTick >= globalInterruptionPeriod) {
lastTick = current;
await delayNextTick();
// prevent calling delayNextTick every iteration of loop
// where delayNextTick takes up the majority or all of the
// globalInterruptionPeriod itself
lastTick = performance.now();
}
if (token.isCancellationRequested) {
throw OperationCancelled;
Expand Down

0 comments on commit a829dfd

Please sign in to comment.