From 2a39a4cdc4fdcf9a7b4d88d0be522c13c41939d4 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 2 Mar 2024 15:20:51 -0600 Subject: [PATCH] Add several TODO comments and minor reformatting --- .../dataObjects/fullData/FullDataPointIdMap.java | 13 +++++++++---- .../core/file/AbstractNewDataSourceHandler.java | 1 - .../seibel/distanthorizons/core/pos/DhLodPos.java | 5 +++++ .../core/util/threading/DhThreadFactory.java | 4 +--- .../threading/RateLimitedThreadPoolExecutor.java | 3 ++- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java index a0d391554..4df982758 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java @@ -36,10 +36,15 @@ import java.util.HashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; /** - * WARNING: This is not THREAD-SAFE! - *

- * Used to map a numerical IDs to a Biome/BlockState pair. - * + * WARNING: This is not THREAD-SAFE!

+ * + * Used to map a numerical IDs to a Biome/BlockState pair.

+ * + * TODO the serializing of this map might be really big + * since it stringifies every block and biome name, which is quite bulky. + * It might be worth while to have a biome and block ID that then both get mapped + * to the data point ID to reduce file size. + * * @author Leetom */ public class FullDataPointIdMap diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractNewDataSourceHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractNewDataSourceHandler.java index c91c4319d..ac003e9f4 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractNewDataSourceHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractNewDataSourceHandler.java @@ -181,7 +181,6 @@ public abstract class AbstractNewDataSourceHandler return CompletableFuture.runAsync(() -> { this.updateDataSourceAtPos(inputDataSource.getSectionPos(), inputDataSource, true); - }, executor); } catch (RejectedExecutionException ignore) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/pos/DhLodPos.java b/core/src/main/java/com/seibel/distanthorizons/core/pos/DhLodPos.java index b2f3cb1f4..1706e9365 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/pos/DhLodPos.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/pos/DhLodPos.java @@ -31,6 +31,11 @@ import java.util.Objects; * * @author Leetom * @version 2022-11-6 + * + * @deprecated TODO replace entirely with DhSectionPos, + * we don't need to have a full fledged position object for + * positions inside a LOD, we only need this position object + * to get to/from the LOD section. */ @Deprecated public class DhLodPos implements Comparable diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/threading/DhThreadFactory.java b/core/src/main/java/com/seibel/distanthorizons/core/util/threading/DhThreadFactory.java index 8eb41b5bc..129e628f2 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/threading/DhThreadFactory.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/threading/DhThreadFactory.java @@ -32,12 +32,10 @@ import org.jetbrains.annotations.NotNull; /** * Just a simple ThreadFactory to name ExecutorService * threads, which is helpful when debugging. - * - * @author James Seibel */ public class DhThreadFactory implements ThreadFactory { - private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName()); + private static final Logger LOGGER = DhLoggerBuilder.getLogger(); public final String threadName; public final int priority; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/threading/RateLimitedThreadPoolExecutor.java b/core/src/main/java/com/seibel/distanthorizons/core/util/threading/RateLimitedThreadPoolExecutor.java index 5b27bb6fb..4b49ade2c 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/threading/RateLimitedThreadPoolExecutor.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/threading/RateLimitedThreadPoolExecutor.java @@ -62,7 +62,7 @@ public class RateLimitedThreadPoolExecutor extends ThreadPoolExecutor { super(corePoolSize, corePoolSize, 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue<>(), + new LinkedBlockingQueue<>(), // TODO using a PriorityBlockingQueue would be nice to allow for prioritizing tasks, but then all tasks must be Comparable threadFactory); this.runTimeRatio = runTimeRatio; @@ -75,6 +75,7 @@ public class RateLimitedThreadPoolExecutor extends ThreadPoolExecutor // overrides // //===========// + @Override protected void beforeExecute(Thread thread, Runnable runnable) { super.beforeExecute(thread, runnable);