From 184f261d6b2a0e3cf0090877be55f81fc4264a31 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 4 Jan 2025 08:58:33 -0600 Subject: [PATCH] Add deprecated Purge to RateLimitedThreadPoolExecutor --- .../RateLimitedThreadPoolExecutor.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 0b4161d9a..a14c1c4f2 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 @@ -25,8 +25,11 @@ import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.ConcurrentModificationException; +import java.util.Iterator; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Supplier; /** * Can be used to more finely control CPU usage and @@ -157,6 +160,20 @@ public class RateLimitedThreadPoolExecutor extends ThreadPoolExecutor implements } } + /** + * Deprecated since most of the time this doesn't do what we want or need. + * In James testing any tasks started with {@link CompletableFuture#runAsync(Runnable, Executor)} + * or {@link CompletableFuture#supplyAsync(Supplier, Executor)} converted the {@link Runnable} + * and {@link CompletableFuture} into objects that didn't support being cancled and removed + * from the queue. The canceled tasks were correctly never run, but couldn't be purged. + */ + @Deprecated + @Override + public void purge() + { + super.purge(); + } + //==============//