stuff
This commit is contained in:
@@ -46,7 +46,7 @@ public class WorldEngine {
|
|||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
this.mapper = new Mapper(this.storage);
|
this.mapper = new Mapper(this.storage);
|
||||||
//5 cache size bits means that the section tracker has 32 separate maps that it uses
|
//5 cache size bits means that the section tracker has 32 separate maps that it uses
|
||||||
this.sectionTracker = new ActiveSectionTracker(5, storage::loadSection, cacheCount, this);
|
this.sectionTracker = new ActiveSectionTracker(7, storage::loadSection, cacheCount, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldSection acquireIfExists(int lvl, int x, int y, int z) {
|
public WorldSection acquireIfExists(int lvl, int x, int y, int z) {
|
||||||
|
|||||||
@@ -90,16 +90,34 @@ public final class WorldSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean tryAcquire() {
|
public boolean tryAcquire() {
|
||||||
|
int prev, next;
|
||||||
|
do {
|
||||||
|
prev = (int) ATOMIC_STATE_HANDLE.get(this);
|
||||||
|
if ((prev&1) == 0) {
|
||||||
|
//The object has been release so early exit
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
next = prev + 2;
|
||||||
|
} while (!ATOMIC_STATE_HANDLE.compareAndSet(this, prev, next));
|
||||||
|
return (next&1) != 0;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
int prev, next;
|
int prev, next;
|
||||||
do {
|
do {
|
||||||
prev = (int) ATOMIC_STATE_HANDLE.get(this);
|
prev = (int) ATOMIC_STATE_HANDLE.get(this);
|
||||||
next = ((prev&1) != 0)?prev+2:prev;
|
next = ((prev&1) != 0)?prev+2:prev;
|
||||||
} while (!ATOMIC_STATE_HANDLE.compareAndSet(this, prev, next));
|
} while (!ATOMIC_STATE_HANDLE.compareAndSet(this, prev, next));
|
||||||
return (next&1) != 0;
|
return (next&1) != 0;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public int acquire() {
|
public int acquire() {
|
||||||
int state =((int) ATOMIC_STATE_HANDLE.getAndAdd(this, 2)) + 2;
|
return this.acquire(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int acquire(int count) {
|
||||||
|
int state =((int) ATOMIC_STATE_HANDLE.getAndAdd(this, count<<1)) + (count<<1);
|
||||||
if (VERIFY_WORLD_SECTION_EXECUTION) {
|
if (VERIFY_WORLD_SECTION_EXECUTION) {
|
||||||
if ((state & 1) == 0) {
|
if ((state & 1) == 0) {
|
||||||
throw new IllegalStateException("Tried to acquire unloaded section");
|
throw new IllegalStateException("Tried to acquire unloaded section");
|
||||||
@@ -259,8 +277,4 @@ public final class WorldSection {
|
|||||||
public static WorldSection _createRawUntrackedUnsafeSection(int lvl, int x, int y, int z) {
|
public static WorldSection _createRawUntrackedUnsafeSection(int lvl, int x, int y, int z) {
|
||||||
return new WorldSection(lvl, x, y, z, null);
|
return new WorldSection(lvl, x, y, z, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActiveSectionTracker _getSectionTracker() {
|
|
||||||
return this.tracker;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ public class VoxyInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected WorldEngine createWorld(SectionStorage storage) {
|
protected WorldEngine createWorld(SectionStorage storage) {
|
||||||
var world = new WorldEngine(storage, 1024);
|
var world = new WorldEngine(storage, 2048);
|
||||||
world.setSaveCallback(this.savingService::enqueueSave);
|
world.setSaveCallback(this.savingService::enqueueSave);
|
||||||
this.activeWorlds.add(world);
|
this.activeWorlds.add(world);
|
||||||
return world;
|
return world;
|
||||||
|
|||||||
Reference in New Issue
Block a user