Change type of connection queue to a concurrent linked queue. Much more efficient, hopefully. Closes #189

This commit is contained in:
Christian 2013-03-10 01:25:36 -05:00
parent b6d98f47a8
commit afb18ee321

View file

@ -7,7 +7,37 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.net.InetSocketAddress;
@@ -77,6 +78,7 @@
@@ -7,6 +8,11 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import com.google.common.collect.Queues;
+
import net.minecraft.logging.ILogAgent;
import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet;
@@ -14,7 +20,7 @@
public class MemoryConnection implements INetworkManager
{
private static final SocketAddress field_74444_a = new InetSocketAddress("127.0.0.1", 0);
- private final List field_74442_b = Collections.synchronizedList(new ArrayList());
+ private final Queue<Packet> field_74442_b = Queues.newConcurrentLinkedQueue();
private final ILogAgent field_98214_c;
private MemoryConnection field_74443_c;
private NetHandler field_74440_d;
@@ -65,7 +71,7 @@
while (i-- >= 0 && !this.field_74442_b.isEmpty())
{
- Packet packet = (Packet)this.field_74442_b.remove(0);
+ Packet packet = field_74442_b.poll();
packet.func_73279_a(this.field_74440_d);
}
@@ -77,6 +83,7 @@
if (this.field_74441_e && this.field_74442_b.isEmpty())
{
this.field_74440_d.func_72515_a(this.field_74438_f, this.field_74439_g);