Fix ConcurrentModificationExceptions
This commit is contained in:
parent
6a06ef6ae0
commit
7034ce11ef
|
@ -161,12 +161,11 @@ class TerminalBlockEntity: DeviceBlockEntity(PhyBlockEntities.TERMINAL),
|
||||||
|
|
||||||
private fun finishPendingRequests() {
|
private fun finishPendingRequests() {
|
||||||
if (world!!.isClient) return
|
if (world!!.isClient) return
|
||||||
|
if (pendingRequests.isEmpty()) return
|
||||||
|
|
||||||
for (request in pendingRequests) {
|
val finishable = pendingRequests.filter { it.isFinishable(counter) }
|
||||||
if (request.isFinishable(counter)) {
|
// stackLocateRequestCompleted removes the object from pendingRequests
|
||||||
stackLocateRequestCompleted(request)
|
finishable.forEach(::stackLocateRequestCompleted)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addObserver() {
|
fun addObserver() {
|
||||||
|
|
|
@ -72,9 +72,10 @@ interface NetworkStackDispatcher<Insertion: NetworkStackDispatcher.PendingInsert
|
||||||
|
|
||||||
fun <Self, Insertion: NetworkStackDispatcher.PendingInsertion<Insertion>> Self.finishTimedOutPendingInsertions() where Self: BlockEntity, Self: NetworkStackDispatcher<Insertion> {
|
fun <Self, Insertion: NetworkStackDispatcher.PendingInsertion<Insertion>> Self.finishTimedOutPendingInsertions() where Self: BlockEntity, Self: NetworkStackDispatcher<Insertion> {
|
||||||
if (world!!.isClient) return
|
if (world!!.isClient) return
|
||||||
|
if (pendingInsertions.isEmpty()) return
|
||||||
|
|
||||||
for (insertion in pendingInsertions) {
|
val finishable = pendingInsertions.filter { it.isFinishable(this) }
|
||||||
if (!insertion.isFinishable(this)) continue
|
// finishInsertion removes the object from pendingInsertions
|
||||||
finishInsertion(insertion)
|
finishable.forEach(::finishInsertion)
|
||||||
}
|
// todo: if a timed-out insertion can't be finished, we should probably retry after some time (exponential backoff?)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue