Merged branch 'jetty-9.3.x' into 'jetty-9.4.x'.

This commit is contained in:
Simone Bordet 2017-02-20 12:06:54 +01:00
commit 49bf2b74d7
1 changed files with 8 additions and 56 deletions

View File

@ -19,13 +19,11 @@
package org.eclipse.jetty.io; package org.eclipse.jetty.io;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Deque;
import java.util.List; import java.util.List;
import java.util.Queue; import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
@ -128,8 +126,7 @@ public interface ByteBufferPool
class Bucket class Bucket
{ {
private final Lock _lock = new ReentrantLock(); private final Deque<ByteBuffer> _queue = new ConcurrentLinkedDeque<>();
private final Queue<ByteBuffer> _queue = new ArrayDeque<>();
private final ByteBufferPool _pool; private final ByteBufferPool _pool;
private final int _capacity; private final int _capacity;
private final AtomicInteger _space; private final AtomicInteger _space;
@ -181,72 +178,27 @@ public interface ByteBufferPool
private void queueOffer(ByteBuffer buffer) private void queueOffer(ByteBuffer buffer)
{ {
Lock lock = _lock; _queue.offerFirst(buffer);
lock.lock();
try
{
_queue.offer(buffer);
}
finally
{
lock.unlock();
}
} }
private ByteBuffer queuePoll() private ByteBuffer queuePoll()
{ {
Lock lock = _lock; return _queue.poll();
lock.lock();
try
{
return _queue.poll();
}
finally
{
lock.unlock();
}
} }
private void queueClear() private void queueClear()
{ {
Lock lock = _lock; _queue.clear();
lock.lock();
try
{
_queue.clear();
}
finally
{
lock.unlock();
}
} }
boolean isEmpty() boolean isEmpty()
{ {
Lock lock = _lock; return _queue.isEmpty();
lock.lock();
try
{
return _queue.isEmpty();
}
finally
{
lock.unlock();
}
} }
int size() int size()
{ {
Lock lock = _lock; return _queue.size();
lock.lock();
try
{
return _queue.size();
}
finally
{
lock.unlock();
}
} }
@Override @Override