set blocks

This commit is contained in:
Jesse Boyd
2019-05-02 04:19:15 +10:00
parent f96760b36c
commit adb2c37a02
7 changed files with 221 additions and 75 deletions

View File

@ -78,6 +78,10 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
// Pool discarded chunks for reuse (can safely be cleared by another thread)
private static final ConcurrentLinkedQueue<IChunk> CHUNK_POOL = new ConcurrentLinkedQueue<>();
public void returnToPool(IChunk chunk) {
CHUNK_POOL.add(chunk);
}
@Override
public <T extends Future<T>> T submit(final IChunk<T> chunk) {
if (chunk.isEmpty()) {
@ -123,7 +127,6 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent {
private IChunk poolOrCreate(final int X, final int Z) {
IChunk next = CHUNK_POOL.poll();
if (next == null) {
System.out.println("Create");
next = create(false);
}
next.init(this, X, Z);

View File

@ -30,6 +30,10 @@ public class CharBlocks implements IBlocks {
for (int i = 0; i < 16; i++) sections[i] = NULL;
}
public void reset(int layer) {
sections[layer] = NULL;
}
protected char[] load(int layer) {
return new char[4096];
}

View File

@ -144,4 +144,8 @@ public enum UnsafeUtils {
public static void writeShort(short[] dest, int destOff, int value) {
UNSAFE.putShort(dest, SHORT_ARRAY_OFFSET + SHORT_ARRAY_SCALE * destOff, (short) value);
}
public static Unsafe getUNSAFE() {
return UNSAFE;
}
}