mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
86 lines
No EOL
3.5 KiB
Diff
86 lines
No EOL
3.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Alfie Cleveland <alfeh@me.com>
|
|
Date: Fri, 25 Nov 2016 20:35:05 +0000
|
|
Subject: [PATCH] Optimise NetworkManager
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
|
|
index 58011bb2f..fb118e90b 100644
|
|
--- a/src/main/java/net/minecraft/server/NetworkManager.java
|
|
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
|
|
@@ -0,0 +0,0 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
|
}
|
|
};
|
|
private final EnumProtocolDirection h;
|
|
- private final Queue<NetworkManager.QueuedPacket> i = Queues.newConcurrentLinkedQueue();
|
|
- private final ReentrantReadWriteLock j = new ReentrantReadWriteLock();
|
|
+ // private final Queue<NetworkManager.QueuedPacket> i = Queues.newConcurrentLinkedQueue(); // Paper
|
|
+ // private final ReentrantReadWriteLock j = new ReentrantReadWriteLock(); // Paper
|
|
public Channel channel;
|
|
// Spigot Start // PAIL
|
|
public SocketAddress l;
|
|
@@ -0,0 +0,0 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
|
if (this.isConnected()) {
|
|
this.m();
|
|
this.a(packet, (GenericFutureListener[]) null);
|
|
- } else {
|
|
- this.j.writeLock().lock();
|
|
-
|
|
- try {
|
|
- this.i.add(new NetworkManager.QueuedPacket(packet, new GenericFutureListener[0]));
|
|
- } finally {
|
|
- this.j.writeLock().unlock();
|
|
- }
|
|
}
|
|
-
|
|
}
|
|
|
|
public void sendPacket(Packet<?> packet, GenericFutureListener<? extends Future<? super Void>> genericfuturelistener, GenericFutureListener<? extends Future<? super Void>>... agenericfuturelistener) {
|
|
if (this.isConnected()) {
|
|
this.m();
|
|
this.a(packet, (GenericFutureListener[]) ArrayUtils.add(agenericfuturelistener, 0, genericfuturelistener));
|
|
- } else {
|
|
- this.j.writeLock().lock();
|
|
-
|
|
- try {
|
|
- this.i.add(new NetworkManager.QueuedPacket(packet, (GenericFutureListener[]) ArrayUtils.add(agenericfuturelistener, 0, genericfuturelistener)));
|
|
- } finally {
|
|
- this.j.writeLock().unlock();
|
|
- }
|
|
}
|
|
-
|
|
}
|
|
|
|
private void a(final Packet<?> packet, @Nullable final GenericFutureListener<? extends Future<? super Void>>[] agenericfuturelistener) {
|
|
@@ -0,0 +0,0 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
|
}
|
|
|
|
private void m() {
|
|
- if (this.channel != null && this.channel.isOpen()) {
|
|
- this.j.readLock().lock();
|
|
-
|
|
- try {
|
|
- while (!this.i.isEmpty()) {
|
|
- NetworkManager.QueuedPacket networkmanager_queuedpacket = (NetworkManager.QueuedPacket) this.i.poll();
|
|
-
|
|
- this.a(networkmanager_queuedpacket.a, networkmanager_queuedpacket.b);
|
|
- }
|
|
- } finally {
|
|
- this.j.readLock().unlock();
|
|
- }
|
|
-
|
|
- }
|
|
+ // Paper - Contents removed
|
|
}
|
|
|
|
public void a() {
|
|
@@ -0,0 +0,0 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
|
} else if (this.i() != null) {
|
|
this.i().a(new ChatComponentText("Disconnected"));
|
|
}
|
|
- this.i.clear(); // Free up packet queue.
|
|
+ // this.i.clear(); // Free up packet queue. // Paper - remove unneeded packet queue
|
|
}
|
|
|
|
}
|
|
--
|