mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-07 00:06:10 +00:00
@@ -9,15 +9,13 @@ public class AtomicCache<T>
|
||||
{
|
||||
private transient volatile T t;
|
||||
private transient volatile long a;
|
||||
private boolean nullSupport;
|
||||
private transient volatile int validations;
|
||||
private final IrisLock check;
|
||||
private final IrisLock time;
|
||||
private final IrisLock write;
|
||||
|
||||
public AtomicCache(boolean nullSupport)
|
||||
public AtomicCache()
|
||||
{
|
||||
this.nullSupport = nullSupport;
|
||||
check = new IrisLock("Check");
|
||||
write = new IrisLock("Write");
|
||||
time = new IrisLock("Time");
|
||||
@@ -26,11 +24,6 @@ public class AtomicCache<T>
|
||||
t = null;
|
||||
}
|
||||
|
||||
public AtomicCache()
|
||||
{
|
||||
this(false);
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
check.lock();
|
||||
@@ -43,43 +36,8 @@ public class AtomicCache<T>
|
||||
check.unlock();
|
||||
}
|
||||
|
||||
public T aquireNullex(Supplier<T> t)
|
||||
{
|
||||
if(validations > 1000)
|
||||
{
|
||||
return this.t;
|
||||
}
|
||||
|
||||
if(M.ms() - a > 1000)
|
||||
{
|
||||
validations++;
|
||||
return this.t;
|
||||
}
|
||||
|
||||
check.lock();
|
||||
write.lock();
|
||||
this.t = t.get();
|
||||
|
||||
time.lock();
|
||||
|
||||
if(a == -1)
|
||||
{
|
||||
a = M.ms();
|
||||
}
|
||||
|
||||
time.unlock();
|
||||
write.unlock();
|
||||
check.unlock();
|
||||
return this.t;
|
||||
}
|
||||
|
||||
public T aquire(Supplier<T> t)
|
||||
{
|
||||
if(nullSupport)
|
||||
{
|
||||
return aquireNullex(t);
|
||||
}
|
||||
|
||||
if(this.t != null && validations > 1000)
|
||||
{
|
||||
return this.t;
|
||||
@@ -97,7 +55,7 @@ public class AtomicCache<T>
|
||||
|
||||
check.lock();
|
||||
|
||||
if(this.t != null)
|
||||
if(this.t == null)
|
||||
{
|
||||
write.lock();
|
||||
this.t = t.get();
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.BlockDataTools;
|
||||
import com.volmit.iris.util.HeightMap;
|
||||
import com.volmit.iris.util.IrisLock;
|
||||
import com.volmit.iris.util.KList;
|
||||
@@ -23,7 +23,7 @@ import lombok.Data;
|
||||
@Data
|
||||
public class AtomicSliver
|
||||
{
|
||||
public static final BlockData AIR = B.getBlockData("AIR");
|
||||
public static final BlockData AIR = BlockDataTools.getBlockData("AIR");
|
||||
private KMap<Integer, BlockData> block;
|
||||
private KMap<Integer, IrisBiome> truebiome;
|
||||
private KMap<Integer, Biome> biome;
|
||||
@@ -75,7 +75,7 @@ public class AtomicSliver
|
||||
lock.unlock();
|
||||
modified = true;
|
||||
|
||||
if(d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(B.mat("CAVE_AIR")))
|
||||
if(d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public class AtomicSliver
|
||||
|
||||
for(int i = 0; i < p; i++)
|
||||
{
|
||||
palette.add(B.getBlockData(din.readUTF()));
|
||||
palette.add(BlockDataTools.getBlockData(din.readUTF()));
|
||||
}
|
||||
|
||||
for(int i = 0; i <= h; i++)
|
||||
|
||||
Reference in New Issue
Block a user