From 8094b68967c4f5e5f600faac319e7d2718e38011 Mon Sep 17 00:00:00 2001 From: Jordan Date: Fri, 24 Jun 2022 10:13:58 +0100 Subject: [PATCH] Actually implement ChunkHolder/ChunkSet pools (#1840) --- .../core/queue/implementation/chunk/ChunkHolder.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/chunk/ChunkHolder.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/chunk/ChunkHolder.java index 805073e86..d54b82ead 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/chunk/ChunkHolder.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/chunk/ChunkHolder.java @@ -67,7 +67,13 @@ public class ChunkHolder> implements IQueueChunk { @Override public synchronized void recycle() { delegate = NULL; - chunkSet = null; + if (chunkSet != null) { + chunkSet.recycle(); + chunkSet = null; + } + chunkExisting = null; + extent = null; + POOL.offer(this); } public synchronized IBlockDelegate getDelegate() { @@ -1039,7 +1045,9 @@ public class ChunkHolder> implements IQueueChunk { chunkSet.setBitMask(bitMask); try { return this.call(chunkSet, () -> { - recycle(); + this.delegate = NULL; + chunkSet.recycle(); + chunkSet = null; calledLock.unlock(stamp); }); } catch (Throwable t) {