jetty-9 improved buffer recycling
This commit is contained in:
parent
03a92fb966
commit
2bb425d0b2
|
@ -64,6 +64,7 @@ public class MappedByteBufferPool implements ByteBufferPool
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release(ByteBuffer buffer)
|
||||
{
|
||||
if (buffer == null)
|
||||
|
@ -82,7 +83,7 @@ public class MappedByteBufferPool implements ByteBufferPool
|
|||
byteBuffers = existing;
|
||||
}
|
||||
|
||||
buffer.clear();
|
||||
BufferUtil.clear(buffer);
|
||||
byteBuffers.offer(buffer);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@ import java.util.concurrent.Executor;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.io.ArrayByteBufferPool;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||
import org.eclipse.jetty.util.FutureCallback;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
|
@ -80,7 +80,7 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
_server=server;
|
||||
_executor=executor!=null?executor:_server.getThreadPool();
|
||||
_scheduler=scheduler!=null?scheduler:new TimerScheduler();
|
||||
_byteBufferPool = pool!=null?pool:new MappedByteBufferPool();
|
||||
_byteBufferPool = pool!=null?pool:new ArrayByteBufferPool();
|
||||
_sslContextFactory = sslContextFactory;
|
||||
|
||||
addBean(_server,false);
|
||||
|
@ -123,6 +123,7 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
return _byteBufferPool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SslContextFactory getSslContextFactory()
|
||||
{
|
||||
return _sslContextFactory;
|
||||
|
|
|
@ -105,6 +105,13 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
|||
|
||||
public void reset()
|
||||
{
|
||||
releaseRequestBuffer();
|
||||
if (_chunk!=null)
|
||||
{
|
||||
_bufferPool.release(_chunk);
|
||||
_chunk=null;
|
||||
}
|
||||
|
||||
// If we are still expecting
|
||||
if (_channel.isExpecting100Continue())
|
||||
{
|
||||
|
@ -123,12 +130,6 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
|||
|
||||
_generator.reset();
|
||||
_channel.reset();
|
||||
releaseRequestBuffer();
|
||||
if (_chunk!=null)
|
||||
{
|
||||
_bufferPool.release(_chunk);
|
||||
_chunk=null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue