From 98dedf374c64678a1c82319588c51b0599ffa06e Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Wed, 23 Mar 2016 16:14:10 -0500 Subject: [PATCH] Removes the cache as it is not in a working state. --- src/main/java/org/ice4j/util/PacketQueue.java | 32 ++----------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/ice4j/util/PacketQueue.java b/src/main/java/org/ice4j/util/PacketQueue.java index 6ccf8ea..296ba41 100644 --- a/src/main/java/org/ice4j/util/PacketQueue.java +++ b/src/main/java/org/ice4j/util/PacketQueue.java @@ -71,17 +71,11 @@ public abstract class PacketQueue /** * Whether this {@link PacketQueue} should store the {@code byte[]} or - * {@code T} instances added to it via on of the {@code add} methods (of + * {@code T} instances added to it via one of the {@code add} methods (if * {@code false}), or create and store a copy (if {@code true}). */ private final boolean copy; - /** - * A cache optionally used to reduce the allocation of new {@code byte[]} - * instances. - */ - private final Queue cache; - /** * The capacity of this {@link PacketQueue}. If one of the {@code add} * methods is called while the queue holds this many packets, the first @@ -147,14 +141,12 @@ public abstract class PacketQueue public PacketQueue( boolean enableStatistics, String id, PacketHandler packetHandler) { - this(DEFAULT_CAPACITY, true, true, enableStatistics, id, packetHandler); + this(DEFAULT_CAPACITY, true, enableStatistics, id, packetHandler); } /** * Initializes a new {@link PacketQueue} instance. * @param capacity the capacity of the queue. - * @param enableCache whether caching of unused {@code byte[]} instances - * should be enabled. * @param copy whether the queue is to store the instances it is given via * the various {@code add} methods, or create a copy. * @param enableStatistics whether detailed statistics should be calculated @@ -168,7 +160,7 @@ public abstract class PacketQueue * created, and the queue will provide access to the head element via * {@link #get()} and {@link #poll()}. */ - public PacketQueue(int capacity, boolean enableCache, boolean copy, + public PacketQueue(int capacity, boolean copy, boolean enableStatistics, String id, PacketHandler packetHandler) { @@ -180,10 +172,6 @@ public abstract class PacketQueue queueStatistics = enableStatistics ? new QueueStatistics(id) : null; - cache - = enableCache - ? new ArrayBlockingQueue(CACHE_CAPACITY) : null; - if (packetHandler != null) { handler = packetHandler; @@ -322,14 +310,6 @@ public abstract class PacketQueue */ private byte[] getByteArray(int len) { - if (cache != null) - { - byte[] buf = cache.poll(); - if (buf != null && buf.length >= len) - { - return buf; - } - } return new byte[len]; } @@ -358,12 +338,6 @@ public abstract class PacketQueue { logger.warning( "Packets dropped (id=" + id + "): " + numDroppedPackets); - - } - - if (cache != null && copy) - { - cache.offer(getBuffer(p)); } } }