From 7a729c39a68d67abfd9fe6b58d9d9ddc15531683 Mon Sep 17 00:00:00 2001 From: RePixelatedMC Date: Wed, 15 Nov 2023 09:58:46 +0100 Subject: [PATCH] e --- .../java/com/volmit/iris/util/mantle/Mantle.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/com/volmit/iris/util/mantle/Mantle.java b/core/src/main/java/com/volmit/iris/util/mantle/Mantle.java index 6630fc019..3d772d452 100644 --- a/core/src/main/java/com/volmit/iris/util/mantle/Mantle.java +++ b/core/src/main/java/com/volmit/iris/util/mantle/Mantle.java @@ -412,7 +412,7 @@ public class Mantle { double adjustedIdleDuration = baseIdleDuration; if (loadedRegions.size() > tectonicLimit) { - adjustedIdleDuration = Math.max(adjustedIdleDuration - ( 1000 * (loadedRegions.size() - tectonicLimit) * 1.35), 4000); + adjustedIdleDuration = Math.max(adjustedIdleDuration - (1000 * (loadedRegions.size() - tectonicLimit) * 1.35), 4000); } io.set(true); @@ -432,11 +432,10 @@ public class Mantle { }); } - // Create a thread pool to handle unloading tasks - ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); + BurstExecutor burstExecutor = new BurstExecutor(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()), toUnload.size()); for (Long i : toUnload) { - executor.submit(() -> { + burstExecutor.queue(() -> { hyperLock.withLong(i, () -> { TectonicPlate m = loadedRegions.get(i); if (m != null) { @@ -454,16 +453,13 @@ public class Mantle { }); } - // Shutdown the executor and wait for tasks to complete - executor.shutdown(); - executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - e.printStackTrace(); + burstExecutor.complete(); + } finally { io.set(false); } } + public long ToUnloadTectonic(){ return FakeToUnload.get(); }