@@ -2,14 +2,13 @@ package org.bukkit.craftbukkit.scheduler;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
class CraftAsyncDebugger {
|
||||
private CraftAsyncDebugger next = null;
|
||||
private final int expiry;
|
||||
private final Plugin plugin;
|
||||
private final Class<?> clazz;
|
||||
|
||||
CraftAsyncDebugger(final int expiry, final Plugin plugin, final Class<?> clazz) {
|
||||
CraftAsyncDebugger(final int expiry, final Plugin plugin, final Class<?> clazz) {
|
||||
this.expiry = expiry;
|
||||
this.plugin = plugin;
|
||||
this.clazz = clazz;
|
||||
|
||||
@@ -25,7 +25,7 @@ class CraftAsyncTask extends CraftTask {
|
||||
@Override
|
||||
public void run() {
|
||||
final Thread thread = Thread.currentThread();
|
||||
synchronized(workers) {
|
||||
synchronized (workers) {
|
||||
if (getPeriod() == CraftTask.CANCEL) {
|
||||
// Never continue running after cancelled.
|
||||
// Checking this with the lock is important!
|
||||
@@ -63,7 +63,7 @@ class CraftAsyncTask extends CraftTask {
|
||||
thrown);
|
||||
} finally {
|
||||
// Cleanup is important for any async task, otherwise ghost tasks are everywhere
|
||||
synchronized(workers) {
|
||||
synchronized (workers) {
|
||||
try {
|
||||
final Iterator<BukkitWorker> workers = this.workers.iterator();
|
||||
boolean removed = false;
|
||||
|
||||
@@ -82,7 +82,12 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
private volatile CraftTask currentTask = null;
|
||||
private volatile int currentTick = -1;
|
||||
private final Executor executor = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("Craft Scheduler Thread - %d").build());
|
||||
private CraftAsyncDebugger debugHead = new CraftAsyncDebugger(-1, null, null) {@Override StringBuilder debugTo(StringBuilder string) {return string;}};
|
||||
private CraftAsyncDebugger debugHead = new CraftAsyncDebugger(-1, null, null) {
|
||||
@Override
|
||||
StringBuilder debugTo(StringBuilder string) {
|
||||
return string;
|
||||
}
|
||||
};
|
||||
private CraftAsyncDebugger debugTail = debugHead;
|
||||
private static final int RECENT_TICKS;
|
||||
|
||||
@@ -248,7 +253,8 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}});
|
||||
}
|
||||
});
|
||||
handle(task, 0L);
|
||||
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
|
||||
if (taskPending == task) {
|
||||
@@ -465,8 +471,8 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
// We split this because of the way things are ordered for all of the async calls in CraftScheduler
|
||||
// (it prevents race-conditions)
|
||||
for (task = head; task != lastTask; task = head) {
|
||||
head = task.getNext();
|
||||
task.setNext(null);
|
||||
head = task.getNext();
|
||||
task.setNext(null);
|
||||
}
|
||||
this.head = lastTask;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user