From d1e58ccf286d5d503e42674b0dec57214840554c Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 5 Mar 2023 18:17:00 -0600 Subject: [PATCH] Refactor GenerationEvent --- .../BatchGenerationEnvironment.java | 2 +- .../worldGeneration/GenerationEvent.java | 29 +++++++++---------- coreSubProjects | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 177939afa..7dd01ed27 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -365,7 +365,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv e.threadedParam.makeStructFeat(region, params); genChunks = new ArrayGridList<>(referencedChunks, RANGE_TO_RANGE_EMPTY_EXTENSION, referencedChunks.gridSize - RANGE_TO_RANGE_EMPTY_EXTENSION); - generateDirect(e, genChunks, e.target, region); + generateDirect(e, genChunks, e.targetGenerationStep, region); e.timer.nextEvent("cleanup"); } catch (StepStructureStart.StructStartCorruptedException f) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java index fe9bc56cd..0165c065c 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java @@ -35,16 +35,16 @@ import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenera import org.apache.logging.log4j.Logger; -//======================= Main Event class====================== public final class GenerationEvent { private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName()); private static int generationFutureDebugIDs = 0; + final int id; final ThreadedParameters threadedParam; final DhChunkPos minPos; final int size; - final Steps target; + final Steps targetGenerationStep; final ELightGenerationMode lightMode; final double runTimeRatio; EventTimer timer = null; @@ -56,13 +56,13 @@ public final class GenerationEvent public GenerationEvent(DhChunkPos minPos, int size, BatchGenerationEnvironment generationGroup, - Steps target, double runTimeRatio, Consumer resultConsumer) + Steps targetGenerationStep, double runTimeRatio, Consumer resultConsumer) { this.inQueueTime = System.nanoTime(); this.id = generationFutureDebugIDs++; this.minPos = minPos; this.size = size; - this.target = target; + this.targetGenerationStep = targetGenerationStep; this.threadedParam = ThreadedParameters.getOrMake(generationGroup.params); this.lightMode = Config.Client.WorldGenerator.lightGenerationMode.get(); this.runTimeRatio = runTimeRatio; @@ -79,18 +79,18 @@ public final class GenerationEvent size += 1; // size must be odd for vanilla world gen regions to work } - GenerationEvent event = new GenerationEvent(minPos, size, generationGroup, target, runTimeRatio, resultConsumer); - event.future = CompletableFuture.runAsync(() -> + GenerationEvent generationEvent = new GenerationEvent(minPos, size, generationGroup, target, runTimeRatio, resultConsumer); + generationEvent.future = CompletableFuture.runAsync(() -> { long runStartTime = System.nanoTime(); - event.timeoutTime = runStartTime; - event.inQueueTime = runStartTime - event.inQueueTime; - event.timer = new EventTimer("setup"); + generationEvent.timeoutTime = runStartTime; + generationEvent.inQueueTime = runStartTime - generationEvent.inQueueTime; + generationEvent.timer = new EventTimer("setup"); BatchGenerationEnvironment.isDistantGeneratorThread.set(true); try { - LOGGER.info("generating [{}]", event.minPos); - generationGroup.generateLodFromList(event); + //LOGGER.info("generating [{}]", event.minPos); + generationGroup.generateLodFromList(generationEvent); } finally { @@ -109,7 +109,7 @@ public final class GenerationEvent } } }, generationGroup.executors); - return event; + return generationEvent; } public boolean isComplete() { return this.future.isDone(); } @@ -156,9 +156,6 @@ public final class GenerationEvent } @Override - public String toString() - { - return this.id + ":" + this.size + "@" + this.minPos + "(" + this.target + ")"; - } + public String toString() { return this.id+":"+this.size+"@"+this.minPos+"("+this.targetGenerationStep +")"; } } \ No newline at end of file diff --git a/coreSubProjects b/coreSubProjects index 32456c311..43de87be0 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 32456c31101bd81935c6802e9ecc3e65f9c2e693 +Subproject commit 43de87be0ddf6864be9ccf8febe8f9c00a46ab0e