* @zh 使用 Worker 并行处理 * @en Worker parallel processing
(entities: readonly Entity[])
| 540 | * @en Worker parallel processing |
| 541 | */ |
| 542 | private async processWithWorker(entities: readonly Entity[]): Promise<void> { |
| 543 | if (!this.workerPool) return; |
| 544 | |
| 545 | const entityData = entities.map(entity => this.extractEntityData(entity)); |
| 546 | const batches = this.createDataBatches(entityData); |
| 547 | const deltaTime = Time.deltaTime; |
| 548 | |
| 549 | const results = await Promise.all( |
| 550 | batches.map(batch => |
| 551 | this.workerPool!.execute<TEntityData[]>({ |
| 552 | entities: batch, |
| 553 | deltaTime, |
| 554 | systemConfig: this.config.systemConfig |
| 555 | }) |
| 556 | ) |
| 557 | ); |
| 558 | |
| 559 | this.applyBatchResults(entities, results); |
| 560 | } |
| 561 | |
| 562 | /** |
| 563 | * @zh 同步处理(fallback) |
nothing calls this directly
no test coverage detected