(workerId: number)
| 279 | } |
| 280 | |
| 281 | private async assignWorkToThread(workerId: number): Promise<void> { |
| 282 | const workItem = await this.getNextWorkItem(workerId); |
| 283 | |
| 284 | const worker = this.workerThreads.get(workerId); |
| 285 | if (!worker) return; |
| 286 | |
| 287 | if (workItem.job) { |
| 288 | worker.postMessage({ |
| 289 | type: "processJob", |
| 290 | data: workItem.job, |
| 291 | }); |
| 292 | } else if (workItem.chunk) { |
| 293 | worker.postMessage({ |
| 294 | type: "processChunk", |
| 295 | data: workItem.chunk, |
| 296 | }); |
| 297 | } else { |
| 298 | setTimeout(() => { |
| 299 | worker.postMessage({ type: "requestWork" }); |
| 300 | }, 1000); |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | private handleWorkCompletion(workerId: number, data: any): void { |
| 305 | this.cleanupWorkerAssignment(workerId); |
no test coverage detected