summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorAfforess <afforess@gmail.com>2011-07-13 17:26:33 -0700
committerEvilSeph <evilseph@gmail.com>2011-07-14 15:49:23 -0400
commit4a932c11dea3444c582f6de3e714d1a644eb7760 (patch)
tree3ab6002ec07f4175e41feacc29666748bcb3ae5c /src/main
parent958acee5aff7dedead270b1098eafb9b12eb6846 (diff)
downloadcraftbukkit-4a932c11dea3444c582f6de3e714d1a644eb7760.tar
craftbukkit-4a932c11dea3444c582f6de3e714d1a644eb7760.tar.gz
craftbukkit-4a932c11dea3444c582f6de3e714d1a644eb7760.tar.lz
craftbukkit-4a932c11dea3444c582f6de3e714d1a644eb7760.tar.xz
craftbukkit-4a932c11dea3444c582f6de3e714d1a644eb7760.zip
Do not immediately re-queue repeating tasks, or they may simply keep repeating on this tick, until the 35ms time limit runs out.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
index 02066909..815b238d 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
@@ -49,6 +49,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
long firstTick = -1;
long currentTick = -1;
CraftTask first = null;
+ TreeMap<CraftTask, Boolean> nextQueue = new TreeMap<CraftTask, Boolean>();
do {
synchronized (schedulerQueue) {
first = null;
@@ -64,7 +65,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
processTask(first);
if (first.getPeriod() >= 0) {
first.updateExecution();
- schedulerQueue.put(first, first.isSync());
+ nextQueue.put(first, first.isSync());
}
} else {
stop = true;
@@ -78,6 +79,10 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
}
} while (!stop);
+ synchronized (schedulerQueue) {
+ schedulerQueue.putAll(nextQueue);
+ }
+
long sleepTime = 0;
if (first == null) {
sleepTime = 60000L;