mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 04:02:50 +01:00
56 lines
2.2 KiB
Diff
56 lines
2.2 KiB
Diff
From 07b0592001e94be3e44f3df2f45214be3a861bb5 Mon Sep 17 00:00:00 2001
|
|
From: md_5 <git@md-5.net>
|
|
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 866148d..4cc436d 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -98,7 +98,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
|
|
private final GameProfileRepository W;
|
|
private final UserCache X;
|
|
private long Y = 0L;
|
|
- protected final Queue<FutureTask<?>> j = Queues.newArrayDeque();
|
|
+ protected final Queue<FutureTask<?>> j = new java.util.concurrent.ConcurrentLinkedQueue<FutureTask<?>>(); // Spigot, PAIL: Rename
|
|
private Thread serverThread;
|
|
private long aa = av();
|
|
|
|
@@ -714,11 +714,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");
|
|
|
|
@@ -1481,10 +1483,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.5.0
|
|
|