world renderer: fix some locking issues

This commit is contained in:
Bixilon 2022-12-23 13:16:18 +01:00
parent 7ce26ba406
commit 5672bacb75
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 6 additions and 6 deletions

View File

@ -227,7 +227,7 @@ class WorldRenderer(
culledQueue.remove(item.chunkPosition, item.sectionHeight, false)
meshingQueue.remove(item)
meshingQueue.remove(item, false)
loadingQueue.abort(item.chunkPosition, false)

View File

@ -55,7 +55,6 @@ class CulledQueue(
if (lock) this.lock.lock()
this.queue.clear()
if (lock) this.lock.unlock()
}
fun remove(position: ChunkPosition, lock: Boolean) {
@ -108,9 +107,10 @@ class CulledQueue(
queueIterator.remove()
}
}
world.chunks.lock.release()
lock.release()
world.chunks.lock.acquire()
return list
}

View File

@ -129,12 +129,12 @@ class ChunkMeshingQueue(
}
fun remove(item: WorldQueueItem) {
this.lock.lock()
fun remove(item: WorldQueueItem, lock: Boolean) {
if (lock) this.lock.lock()
if (this.set.remove(item)) {
this.queue -= item
}
this.lock.unlock()
if (lock) this.lock.unlock()
}