mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Changes made to GlobalBlockQueue to help diagnose lag.
This commit is contained in:
parent
fd6fbebd69
commit
ecfb71b08f
@ -8,6 +8,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.ConcurrentModificationException;
|
import java.util.ConcurrentModificationException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
@ -38,8 +39,7 @@ public class GlobalBlockQueue {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} while (((GlobalBlockQueue.this.secondLast = System.currentTimeMillis())
|
} while (((GlobalBlockQueue.this.secondLast = System.currentTimeMillis())- GlobalBlockQueue.this.last) < free);
|
||||||
- GlobalBlockQueue.this.last) < free);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -81,50 +81,50 @@ public class GlobalBlockQueue {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
running.set(true);
|
running.set(true);
|
||||||
TaskManager.runTaskRepeat(() -> {
|
TaskManager.runTaskRepeat(new Runnable() {
|
||||||
if (inactiveQueues.isEmpty() && activeQueues.isEmpty()) {
|
@Override public void run() {
|
||||||
lastSuccess = System.currentTimeMillis();
|
if (inactiveQueues.isEmpty() && activeQueues.isEmpty()) {
|
||||||
tasks();
|
lastSuccess = System.currentTimeMillis();
|
||||||
return;
|
GlobalBlockQueue.this.tasks();
|
||||||
}
|
return;
|
||||||
SET_TASK.value1 = 50 + Math.min(
|
}
|
||||||
(50 + GlobalBlockQueue.this.last) - (GlobalBlockQueue.this.last =
|
SET_TASK.value1 = 50 + Math.min((50 + GlobalBlockQueue.this.last) - (GlobalBlockQueue.this.last = System.currentTimeMillis()),
|
||||||
System.currentTimeMillis()),
|
GlobalBlockQueue.this.secondLast - System.currentTimeMillis());
|
||||||
GlobalBlockQueue.this.secondLast - System.currentTimeMillis());
|
SET_TASK.value2 = GlobalBlockQueue.this.getNextQueue();
|
||||||
SET_TASK.value2 = getNextQueue();
|
if (SET_TASK.value2 == null) {
|
||||||
if (SET_TASK.value2 == null) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
|
||||||
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
|
throw new IllegalStateException(
|
||||||
throw new IllegalStateException(
|
"This shouldn't be possible for placement to occur off the main thread");
|
||||||
"This shouldn't be possible for placement to occur off the main thread");
|
}
|
||||||
}
|
// Disable the async catcher as it can't discern async vs parallel
|
||||||
// Disable the async catcher as it can't discern async vs parallel
|
SET_TASK.value2.startSet(true);
|
||||||
SET_TASK.value2.startSet(true);
|
try {
|
||||||
try {
|
if (PARALLEL_THREADS <= 1) {
|
||||||
if (PARALLEL_THREADS <= 1) {
|
SET_TASK.run();
|
||||||
SET_TASK.run();
|
} else {
|
||||||
} else {
|
ArrayList<Thread> threads = new ArrayList<>();
|
||||||
ArrayList<Thread> threads = new ArrayList<>();
|
for (int i = 0; i < PARALLEL_THREADS; i++) {
|
||||||
for (int i = 0; i < PARALLEL_THREADS; i++) {
|
threads.add(new Thread(SET_TASK));
|
||||||
threads.add(new Thread(SET_TASK));
|
}
|
||||||
}
|
for (Thread thread : threads) {
|
||||||
for (Thread thread : threads) {
|
thread.start();
|
||||||
thread.start();
|
}
|
||||||
}
|
for (Thread thread : threads) {
|
||||||
for (Thread thread : threads) {
|
try {
|
||||||
try {
|
thread.join();
|
||||||
thread.join();
|
} catch (InterruptedException e) {
|
||||||
} catch (InterruptedException e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
// Enable it again (note that we are still on the main thread)
|
||||||
|
SET_TASK.value2.endSet(true);
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
// Enable it again (note that we are still on the main thread)
|
|
||||||
SET_TASK.value2.endSet(true);
|
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
return true;
|
return true;
|
||||||
@ -205,7 +205,9 @@ public class GlobalBlockQueue {
|
|||||||
} else {
|
} else {
|
||||||
ArrayList<Thread> threads = new ArrayList<>();
|
ArrayList<Thread> threads = new ArrayList<>();
|
||||||
for (int i = 0; i < PARALLEL_THREADS; i++) {
|
for (int i = 0; i < PARALLEL_THREADS; i++) {
|
||||||
threads.add(new Thread(SET_TASK));
|
Thread thread = new Thread(SET_TASK);
|
||||||
|
thread.setName("PlotSquared Flush Task");
|
||||||
|
threads.add(thread);
|
||||||
}
|
}
|
||||||
for (Thread thread : threads) {
|
for (Thread thread : threads) {
|
||||||
thread.start();
|
thread.start();
|
||||||
|
Loading…
Reference in New Issue
Block a user