Fix parallax deadlocking

This commit is contained in:
Daniel Mills
2020-12-13 09:37:58 -05:00
parent 5b74f8f836
commit 73360bb66c
6 changed files with 65 additions and 48 deletions

View File

@@ -3,7 +3,6 @@ package com.volmit.iris.scaffold.engine;
import com.volmit.iris.generator.IrisComplex;
import com.volmit.iris.manager.IrisDataManager;
import com.volmit.iris.scaffold.data.DataProvider;
import com.volmit.iris.util.M;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
@@ -21,15 +20,8 @@ public interface EngineFramework extends DataProvider
default void recycle()
{
if(M.r(0.1))
{
synchronized (getEngine().getParallax())
{
getEngine().getParallax().cleanup();
}
getData().getObjectLoader().clean();
}
getEngine().getParallax().cleanup();
getData().getObjectLoader().clean();
}
public EngineActuator<BlockData> getTerrainActuator();

View File

@@ -9,9 +9,9 @@ import java.io.IOException;
public class HunkRegionSlice<T>
{
public static final Function2<Integer, CompoundTag, HunkRegionSlice<BlockData>> BLOCKDATA = (h, c) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new BlockDataHunkIOAdapter(), c, "blockdata");
public static final Function3<Integer, CompoundTag, String, HunkRegionSlice<String>> STRING = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new StringHunkIOAdapter(), c, t);
public static final Function3<Integer, CompoundTag, String, HunkRegionSlice<Boolean>> BOOLEAN = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new BooleanHunkIOAdapter(), c, t);
public static final Function2<Integer, CompoundTag, HunkRegionSlice<BlockData>> BLOCKDATA = (h, c) -> new HunkRegionSlice<>(h, Hunk::newAtomicHunk, new BlockDataHunkIOAdapter(), c, "blockdata");
public static final Function3<Integer, CompoundTag, String, HunkRegionSlice<String>> STRING = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newAtomicHunk, new StringHunkIOAdapter(), c, t);
public static final Function3<Integer, CompoundTag, String, HunkRegionSlice<Boolean>> BOOLEAN = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newAtomicHunk, new BooleanHunkIOAdapter(), c, t);
private final Function3<Integer, Integer, Integer, Hunk<T>> factory;
private final HunkIOAdapter<T> adapter;
private final CompoundTag compound;

View File

@@ -90,7 +90,7 @@ public class ParallaxRegion extends HunkRegion
return getMetaHunkR();
}
public synchronized Hunk<ParallaxChunkMeta> loadMetaHunk()
public Hunk<ParallaxChunkMeta> loadMetaHunk()
{
lastUse = M.ms();
if(meta == null)
@@ -115,7 +115,7 @@ public class ParallaxRegion extends HunkRegion
return meta;
}
public synchronized void unloadMetaHunk()
public void unloadMetaHunk()
{
if(dirtyMeta)
{
@@ -126,7 +126,7 @@ public class ParallaxRegion extends HunkRegion
meta = null;
}
public synchronized void saveMetaHunk()
public void saveMetaHunk()
{
if(meta != null && dirtyMeta)
{

View File

@@ -54,7 +54,7 @@ public class ParallaxWorld implements ParallaxAccess
return m;
}
public synchronized void close()
public void close()
{
for(ParallaxRegion i : loadedRegions.v())
{
@@ -65,7 +65,7 @@ public class ParallaxWorld implements ParallaxAccess
loadedRegions.clear();
}
public synchronized void save(ParallaxRegion region)
public void save(ParallaxRegion region)
{
try
{
@@ -83,7 +83,7 @@ public class ParallaxWorld implements ParallaxAccess
return loadedRegions.containsKey(key(x, z));
}
public synchronized void save(int x, int z)
public void save(int x, int z)
{
if(isLoaded(x, z))
{
@@ -91,7 +91,7 @@ public class ParallaxWorld implements ParallaxAccess
}
}
public synchronized void unload(int x, int z)
public void unload(int x, int z)
{
long key = key(x, z);
@@ -107,7 +107,7 @@ public class ParallaxWorld implements ParallaxAccess
}
}
public synchronized ParallaxRegion load(int x, int z)
public ParallaxRegion load(int x, int z)
{
if(isLoaded(x, z))
{
@@ -157,7 +157,7 @@ public class ParallaxWorld implements ParallaxAccess
}
@Override
public synchronized Hunk<BlockData> getBlocksRW(int x, int z)
public Hunk<BlockData> getBlocksRW(int x, int z)
{
return getRW(x >> 5, z >> 5).getBlockSlice().getRW(x & 31, z & 31);
}
@@ -169,7 +169,7 @@ public class ParallaxWorld implements ParallaxAccess
}
@Override
public synchronized Hunk<String> getObjectsRW(int x, int z)
public Hunk<String> getObjectsRW(int x, int z)
{
return getRW(x >> 5, z >> 5).getObjectSlice().getRW(x & 31, z & 31);
}
@@ -181,7 +181,7 @@ public class ParallaxWorld implements ParallaxAccess
}
@Override
public synchronized Hunk<Boolean> getUpdatesRW(int x, int z)
public Hunk<Boolean> getUpdatesRW(int x, int z)
{
return getRW(x >> 5, z >> 5).getUpdateSlice().getRW(x & 31, z & 31);
}
@@ -227,15 +227,12 @@ public class ParallaxWorld implements ParallaxAccess
}
@Override
public synchronized void saveAllNOW() {
public void saveAllNOW() {
for(ParallaxRegion i : loadedRegions.v())
{
synchronized (save)
if(save.contains(key(i.getX(), i.getZ())))
{
if(save.contains(key(i.getX(), i.getZ())))
{
save(i.getX(), i.getZ());
}
save(i.getX(), i.getZ());
}
}
}