From 4b4dbc75c3c618e917893695727b995edbc32dac Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 19 Apr 2015 09:19:39 +1000 Subject: [PATCH] Use CLQ for main thread tasks. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 9bf5415..1d29ae7 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -100,7 +100,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs private long X = 0L; private final GameProfileRepository Y; private final UserCache Z; - protected final Queue> j = Queues.newArrayDeque(); + protected final Queue> j = new java.util.concurrent.ConcurrentLinkedQueue>(); // Spigot, PAIL: Rename private Thread serverThread; private long ab = az(); @@ -708,11 +708,13 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs this.methodProfiler.a("jobs"); Queue queue = this.j; - synchronized (this.j) { - while (!this.j.isEmpty()) { - SystemUtils.a((FutureTask) this.j.poll(), MinecraftServer.LOGGER); - } - } + // Spigot start + FutureTask entry; + int count = this.j.size(); + while (count-- > 0 && (entry = this.j.poll()) != null) { + SystemUtils.a(entry, MinecraftServer.LOGGER); + } + // Spigot end this.methodProfiler.c("levels"); @@ -1496,10 +1498,10 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs ListenableFutureTask listenablefuturetask = ListenableFutureTask.create(callable); Queue queue = this.j; - synchronized (this.j) { - this.j.add(listenablefuturetask); - return listenablefuturetask; - } + // Spigot start + this.j.add(listenablefuturetask); + return listenablefuturetask; + // Spigot end } else { try { return Futures.immediateFuture(callable.call()); -- 2.1.4