Implemented buffer pooling.
This commit is contained in:
parent
194dcb7bc9
commit
c2abdfb2e2
|
@ -19,6 +19,7 @@ package org.eclipse.jetty.spdy;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
public class StandardByteBufferPool implements ByteBufferPool
|
public class StandardByteBufferPool implements ByteBufferPool
|
||||||
|
@ -61,21 +62,21 @@ public class StandardByteBufferPool implements ByteBufferPool
|
||||||
|
|
||||||
public void release(ByteBuffer buffer)
|
public void release(ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
// int bucket = bucketFor(buffer.capacity());
|
int bucket = bucketFor(buffer.capacity());
|
||||||
// ConcurrentMap<Integer, Queue<ByteBuffer>> buffers = buffersFor(buffer.isDirect());
|
ConcurrentMap<Integer, Queue<ByteBuffer>> buffers = buffersFor(buffer.isDirect());
|
||||||
//
|
|
||||||
// // Avoid to create a new queue every time, just to be discarded immediately
|
// Avoid to create a new queue every time, just to be discarded immediately
|
||||||
// Queue<ByteBuffer> byteBuffers = buffers.get(bucket);
|
Queue<ByteBuffer> byteBuffers = buffers.get(bucket);
|
||||||
// if (byteBuffers == null)
|
if (byteBuffers == null)
|
||||||
// {
|
{
|
||||||
// byteBuffers = new ConcurrentLinkedQueue<>();
|
byteBuffers = new ConcurrentLinkedQueue<>();
|
||||||
// Queue<ByteBuffer> existing = buffers.putIfAbsent(bucket, byteBuffers);
|
Queue<ByteBuffer> existing = buffers.putIfAbsent(bucket, byteBuffers);
|
||||||
// if (existing != null)
|
if (existing != null)
|
||||||
// byteBuffers = existing;
|
byteBuffers = existing;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// buffer.clear();
|
buffer.clear();
|
||||||
// byteBuffers.offer(buffer);
|
byteBuffers.offer(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear()
|
public void clear()
|
||||||
|
|
Loading…
Reference in New Issue