* Runs every task whose deadline has passed, then schedules the next wakeup * if there is still pending work.
()
| 73 | * if there is still pending work. |
| 74 | */ |
| 75 | private process(): void { |
| 76 | this.timeoutId = null |
| 77 | const now = Date.now() |
| 78 | for (const [key, task] of this.tasks.entries()) { |
| 79 | if (now >= task.executeAt) { |
| 80 | this.tasks.delete(key) |
| 81 | try { |
| 82 | task.callback() |
| 83 | } catch (error) { |
| 84 | console.error('Error in CleanupQueue task:', error) |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | if (this.tasks.size > 0) { |
| 90 | this.updateTimeout() |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Resets the singleton instance for tests. |
no test coverage detected