Skip to content

Commit

Permalink
wip: optimize method has
Browse files Browse the repository at this point in the history
  • Loading branch information
burivuhster committed Jan 14, 2025
1 parent ffd5f00 commit a5ee240
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/cli/src/concurrency/concurrency-control.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ export class ConcurrencyControlService {
has(executionId: string) {
if (!this.isEnabled) return false;

return Array.from(this.queues.values()).some((queue) => queue.getAll().has(executionId));
for (const queue of this.queues.values()) {
if (queue.has(executionId)) {
return true;
}
}

return false;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/concurrency/concurrency-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export class ConcurrencyQueue extends TypedEmitter<ConcurrencyEvents> {
return new Set(this.queue.map((item) => item.executionId));
}

has(executionId: string) {
return this.queue.some((item) => item.executionId === executionId);
}

private resolveNext() {
const item = this.queue.shift();

Expand Down

0 comments on commit a5ee240

Please sign in to comment.