(callback: () => void | Promise<void>, delayMs: number)
| 92 | timer = setTimeout(async () => { |
| 93 | this.pendingTimeouts.delete(timer); |
| 94 | try { |
| 95 | await callback(); |
| 96 | } catch (error) { |
| 97 | console.error("[autodelcmd] 定时任务执行失败:", error); |
| 98 | } |
| 99 | }, delayMs); |
| 100 | this.pendingTimeouts.add(timer); |
| 101 | return timer; |
| 102 | } |
| 103 | |
| 104 | public cleanup(): void { |
| 105 | // 真实资源清理:释放插件持有的定时器、监听器、运行时状态或临时资源。 |
| 106 | for (const timer of this.pendingTimeouts) { |
| 107 | clearTimeout(timer); |
| 108 | } |
| 109 | this.pendingTimeouts.clear(); |
no test coverage detected