()
| 266 | * 关闭 Worker(同步版本,用于一般场景) |
| 267 | */ |
| 268 | export function closeWorker(): void { |
| 269 | if (worker) { |
| 270 | // 先关闭所有数据库连接 |
| 271 | sendToWorker('closeAll', {}).catch(() => {}) |
| 272 | |
| 273 | worker.terminate() |
| 274 | worker = null |
| 275 | rejectAllPending(new Error('Worker terminated')) |
| 276 | console.log('[WorkerManager] Worker terminated') |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * 关闭 Worker(异步版本,确保数据库连接关闭后再终止) |
nothing calls this directly
no test coverage detected