better debug logging + fix tracking crash

This commit is contained in:
mcrcortex
2025-05-29 23:11:04 +10:00
parent fe2e6522ed
commit 6c6c08d188
2 changed files with 13 additions and 5 deletions

View File

@@ -648,8 +648,12 @@ public class AsyncNodeManager {
public void addTopLevel(long section) {//Only called from render thread
if (!this.running) throw new IllegalStateException("Not running");
long stamp = this.tlnLock.writeLock();
int state = this.tlnAdd.add(section)?1:0;
state -= this.tlnRem.remove(section)?1:0;
int state = 0;
if (!this.tlnRem.remove(section)) {
state += this.tlnAdd.add(section)?1:0;
} else {
state -= 1;
}
if (state != 0) {
if (this.workCounter.getAndAdd(state) == 0) {
LockSupport.unpark(this.thread);
@@ -661,8 +665,12 @@ public class AsyncNodeManager {
public void removeTopLevel(long section) {//Only called from render thread
if (!this.running) throw new IllegalStateException("Not running");
long stamp = this.tlnLock.writeLock();
int state = this.tlnRem.add(section)?1:0;
state -= this.tlnAdd.remove(section)?1:0;
int state = 0;
if (!this.tlnAdd.remove(section)) {
state += this.tlnRem.add(section)?1:0;
} else {
state -= 1;
}
if (state != 0) {
if (this.workCounter.getAndAdd(state) == 0) {
LockSupport.unpark(this.thread);

View File

@@ -162,7 +162,7 @@ public class NodeManager {
public void removeTopLevelNode(long pos) {
if (!this.topLevelNodes.remove(pos)) {
throw new IllegalStateException("Position not in top level map");
throw new IllegalStateException("Position not in top level map: " + WorldEngine.pprintPos(pos));
}
int nodeId = this.activeSectionMap.get(pos);
if (nodeId == -1) {