mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-07 16:26:14 +00:00
Fix parallax deadlocking
This commit is contained in:
@@ -3,8 +3,6 @@ package com.volmit.iris.generator;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.scaffold.engine.*;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.ChronoLatch;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
@@ -52,7 +50,6 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
private volatile int minHeight;
|
||||
private int permits;
|
||||
private boolean failing;
|
||||
private ChronoLatch cl = new ChronoLatch(10000);
|
||||
private boolean closed;
|
||||
private int cacheId;
|
||||
private Semaphore s;
|
||||
@@ -62,7 +59,7 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
{
|
||||
Iris.info("Initializing Engine: " + target.getWorld().getName() + "/" + target.getDimension().getLoadKey() + " (" + target.getHeight() + " height)");
|
||||
metrics = new EngineMetrics(32);
|
||||
permits = 1000;
|
||||
permits = 10000;
|
||||
this.s = new Semaphore(permits);
|
||||
this.target = target;
|
||||
this.framework = new IrisEngineFramework(this);
|
||||
@@ -127,19 +124,7 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
getFramework().getEngineParallax().insertParallax(x, z, fringe);
|
||||
getMetrics().getTotal().put(p.getMilliseconds());
|
||||
s.release(1);
|
||||
|
||||
if(cl.flip())
|
||||
{
|
||||
MultiBurst.burst.lazy(() -> {
|
||||
try {
|
||||
s.acquire(permits);
|
||||
getFramework().recycle();
|
||||
s.release(permits);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
getFramework().recycle();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
package com.volmit.iris.generator;
|
||||
|
||||
import com.volmit.iris.generator.actuator.*;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.generator.actuator.IrisBiomeActuator;
|
||||
import com.volmit.iris.generator.actuator.IrisDecorantActuator;
|
||||
import com.volmit.iris.generator.actuator.IrisTerrainActuator;
|
||||
import com.volmit.iris.generator.modifier.IrisCaveModifier;
|
||||
import com.volmit.iris.generator.modifier.IrisDepositModifier;
|
||||
import com.volmit.iris.generator.modifier.IrisPostModifier;
|
||||
import com.volmit.iris.generator.modifier.IrisRavineModifier;
|
||||
import com.volmit.iris.scaffold.engine.*;
|
||||
import com.volmit.iris.util.ChronoLatch;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class IrisEngineFramework implements EngineFramework {
|
||||
|
||||
@Getter
|
||||
@@ -42,6 +49,9 @@ public class IrisEngineFramework implements EngineFramework {
|
||||
@Getter
|
||||
private final EngineModifier<BlockData> postModifier;
|
||||
|
||||
private final AtomicBoolean cleaning;
|
||||
private final ChronoLatch cleanLatch;
|
||||
|
||||
public IrisEngineFramework(Engine engine)
|
||||
{
|
||||
this.engine = engine;
|
||||
@@ -54,6 +64,39 @@ public class IrisEngineFramework implements EngineFramework {
|
||||
this.ravineModifier = new IrisRavineModifier(getEngine());
|
||||
this.caveModifier = new IrisCaveModifier(engine);
|
||||
this.postModifier = new IrisPostModifier(engine);
|
||||
cleaning = new AtomicBoolean(false);
|
||||
cleanLatch = new ChronoLatch(Math.max(10000, Math.min(IrisSettings.get().parallaxChunkEvictionMS, IrisSettings.get().parallaxRegionEvictionMS)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void recycle() {
|
||||
if(!cleanLatch.flip())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (cleaning.get())
|
||||
{
|
||||
cleanLatch.flipDown();
|
||||
return;
|
||||
}
|
||||
|
||||
cleaning.set(true);
|
||||
|
||||
try
|
||||
{
|
||||
getEngine().getParallax().cleanup();
|
||||
getData().getObjectLoader().clean();
|
||||
Iris.verbose("Ran Cleanup");
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
Iris.error("Cleanup failed!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
cleaning.lazySet(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user