3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-05 11:00:05 +01:00

Synchronise access to the PriorityQueue used for effect queuing in AbstractWorld

- Makes it thread-safe
Dieser Commit ist enthalten in:
dordsor21 2022-01-15 17:09:49 +00:00
Ursprung 0ccae19ded
Commit d3696f91d4
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B

Datei anzeigen

@ -111,14 +111,18 @@ public abstract class AbstractWorld implements World {
public boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority) {
if (taskId == -1) {
taskId = server.schedule(0, 1, () -> {
int max = Math.max(1, Math.min(30, effectQueue.size() / 3));
for (int i = 0; i < max; ++i) {
if (effectQueue.isEmpty()) {
return;
}
//FAWE start - access to PriorityQueue is not thread-safe
synchronized (effectQueue) {
int max = Math.max(1, Math.min(30, effectQueue.size() / 3));
for (int i = 0; i < max; ++i) {
if (effectQueue.isEmpty()) {
return;
}
effectQueue.poll().play();
effectQueue.poll().play();
}
}
//FAWE end
});
}
@ -126,7 +130,11 @@ public abstract class AbstractWorld implements World {
return false;
}
effectQueue.offer(new QueuedEffect(position.toVector3(), blockType, priority));
//FAWE start - access to PriorityQueue is not thread-safe
synchronized (effectQueue) {
effectQueue.offer(new QueuedEffect(position.toVector3(), blockType, priority));
}
//FAWE end
return true;
}