diff --git a/src/adapter/z-stack/adapter/zStackAdapter.ts b/src/adapter/z-stack/adapter/zStackAdapter.ts index bf93c6b4ff..5c969d06d9 100644 --- a/src/adapter/z-stack/adapter/zStackAdapter.ts +++ b/src/adapter/z-stack/adapter/zStackAdapter.ts @@ -417,6 +417,7 @@ class ZStackAdapter extends Adapter { disableRecovery: boolean, sourceEndpoint?: number, ): Promise { + logger.debug(`== sendZclFrameToEndpoint add to queue - ${ieeeAddr}/${networkAddress}`, NS); return await this.queue.execute(async () => { this.checkInterpanLock(); return await this.sendZclFrameToEndpointInternal( diff --git a/src/utils/queue.ts b/src/utils/queue.ts index b10911bb28..6e7cf09109 100644 --- a/src/utils/queue.ts +++ b/src/utils/queue.ts @@ -1,9 +1,13 @@ +import {logger} from './logger'; + interface Job { key?: string | number; running: boolean; start?: () => void; } +const NS = 'zh:queue'; + class Queue { private jobs: Job[]; private readonly concurrent: number; @@ -14,6 +18,7 @@ class Queue { } public async execute(func: () => Promise, key?: string | number): Promise { + logger.debug(`== queue add - ${key} (keys=${this.jobs.map((j) => j.key)})`, NS); const job: Job = {key, running: false}; this.jobs.push(job); @@ -33,9 +38,11 @@ class Queue { } try { + logger.debug(`== queue execute func - ${key} (keys=${this.jobs.map((j) => j.key)})`, NS); return await func(); } finally { this.jobs.splice(this.jobs.indexOf(job), 1); + logger.debug(`== queue remove - ${key} (keys=${this.jobs.map((j) => j.key)})`, NS); this.executeNext(); } }