From e94e3b7b05c33b23f284fded10de986c8a8c6829 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 13 Jan 2021 18:17:18 +0000 Subject: [PATCH] Only forcefully submit a chunk if we hold the monitor. - Properly ensures we don't try to submit chunks that already have a monitor (prevent the FAWE-freezing) - We can't detect if "no" threads hold the chunk's monitor, but equally that would also be kinda very bad practice. --- .../queue/SingleThreadQueueExtent.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java index 25c64cbcf..6569ec61c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java @@ -250,8 +250,19 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen // - memory is low & queue size > num threads + 8 // - queue size > target size and primary queue has less than num threads submissions if (enabledQueue && ((lowMem && size > Settings.IMP.QUEUE.PARALLEL_THREADS + 8) || (size > Settings.IMP.QUEUE.TARGET_SIZE && Fawe.get().getQueueHandler().isUnderutilized()))) { - chunk = chunks.removeFirst(); - final Future future = submitUnchecked(chunk); + int i = 0; + boolean found = false; + while (i < chunks.size() && (chunk = chunks.get(i)) != null) { + if (Thread.holdsLock(chunk)) { + found = true; + break; + } + i++; + } + Future future = null; + if (found) { + future = submitUnchecked(chunk); + } if (future != null && !future.isDone()) { final int targetSize; if (lowMem) {