MCPcopy Create free account
hub / github.com/esengine/esengine / processWithWorker

Function processWithWorker

packages/core/src/ECS/Systems/WorkerEntitySystem.ts:542–560  ·  view source on GitHub ↗

* @zh 使用 Worker 并行处理 * @en Worker parallel processing

(entities: readonly Entity[])

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 4

executeMethod · 0.65
mapMethod · 0.45
extractEntityDataMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected