From c62b849911c3acc3a8fc72f2c036ce9fa47ccd9d Mon Sep 17 00:00:00 2001 From: lisong <8167@carpoly.com> Date: Thu, 6 Mar 2025 16:16:15 +0800 Subject: [PATCH] fix: Move up the #_busy flag to fix the synchronization queue cannot start again . --- src/TaskRunner.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/TaskRunner.ts b/src/TaskRunner.ts index 7294d8f..971c27d 100644 --- a/src/TaskRunner.ts +++ b/src/TaskRunner.ts @@ -123,6 +123,8 @@ export class TaskRunner { #run() { if (this.#completed !== this.#total) { if (!this.#_paused && this.#running < this.#_concurrency) { + this.#_busy = true; + const difference = this.#_concurrency - this.#running; const tasks = this.#_pending.removeRange(0, difference) as Tasks; @@ -139,10 +141,9 @@ export class TaskRunner { task, }); }); - - this.#_busy = true; } } else { + this.#_busy = false; this.#_duration.end = Date.now(); this.#_duration.total = Math.ceil( this.#_duration.end - this.#_duration.start @@ -150,8 +151,6 @@ export class TaskRunner { /* istanbul ignore next */ this.#runHook(RunnerEvents.END); - - this.#_busy = false; } }