Switching to direct ByteBuffers

This commit is contained in:
Joakim Erdfelt 2013-02-22 12:57:36 -07:00
parent a619abdfe7
commit 5621f87c81
9 changed files with 12 additions and 12 deletions

View File

@ -117,7 +117,7 @@ public class UpgradeConnection extends AbstractConnection
@Override @Override
public void onFillable() public void onFillable()
{ {
ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),false); ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),true);
BufferUtil.clear(buffer); BufferUtil.clear(buffer);
boolean readMore = false; boolean readMore = false;
try try

View File

@ -72,7 +72,7 @@ public class ServerReadThread extends Thread
public void run() public void run()
{ {
ByteBufferPool bufferPool = conn.getBufferPool(); ByteBufferPool bufferPool = conn.getBufferPool();
ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false); ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,true);
BufferUtil.clearToFill(buf); BufferUtil.clearToFill(buf);
int len = 0; int len = 0;

View File

@ -310,7 +310,7 @@ public class BlockheadServer
LOG.debug("Read: waiting for {} frame(s) from server",expectedCount); LOG.debug("Read: waiting for {} frame(s) from server",expectedCount);
int startCount = incomingFrames.size(); int startCount = incomingFrames.size();
ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false); ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,true);
BufferUtil.clearToFill(buf); BufferUtil.clearToFill(buf);
try try
{ {
@ -403,7 +403,7 @@ public class BlockheadServer
{ {
LOG.debug("Entering echo thread"); LOG.debug("Entering echo thread");
ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false); ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,true);
BufferUtil.clearToFill(buf); BufferUtil.clearToFill(buf);
long readBytes = 0; long readBytes = 0;
try try

View File

@ -222,7 +222,7 @@ public class Generator
/* /*
* prepare the byte buffer to put frame into * prepare the byte buffer to put frame into
*/ */
ByteBuffer buffer = bufferPool.acquire(windowSize,false); ByteBuffer buffer = bufferPool.acquire(windowSize,true);
BufferUtil.clearToFill(buffer); BufferUtil.clearToFill(buffer);
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
{ {

View File

@ -553,7 +553,7 @@ public class Parser
if (payload == null) if (payload == null)
{ {
frame.assertValid(); frame.assertValid();
payload = bufferPool.acquire(payloadLength,false); payload = bufferPool.acquire(payloadLength,true);
BufferUtil.clearToFill(payload); BufferUtil.clearToFill(payload);
} }

View File

@ -57,7 +57,7 @@ public class MuxGenerator
public void generate(long channelId, Frame frame, WriteCallback callback) public void generate(long channelId, Frame frame, WriteCallback callback)
{ {
ByteBuffer muxPayload = bufferPool.acquire(frame.getPayloadLength() + DATA_FRAME_OVERHEAD,false); ByteBuffer muxPayload = bufferPool.acquire(frame.getPayloadLength() + DATA_FRAME_OVERHEAD,true);
BufferUtil.flipToFill(muxPayload); BufferUtil.flipToFill(muxPayload);
// start building mux payload // start building mux payload
@ -90,7 +90,7 @@ public class MuxGenerator
return; // nothing to do return; // nothing to do
} }
ByteBuffer payload = bufferPool.acquire(CONTROL_BUFFER_SIZE,false); ByteBuffer payload = bufferPool.acquire(CONTROL_BUFFER_SIZE,true);
BufferUtil.flipToFill(payload); BufferUtil.flipToFill(payload);
writeChannelId(payload,0); // control channel writeChannelId(payload,0); // control channel

View File

@ -404,7 +404,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
{ {
LOG.debug("{} onFillable()",policy.getBehavior()); LOG.debug("{} onFillable()",policy.getBehavior());
stats.countOnFillableEvents.incrementAndGet(); stats.countOnFillableEvents.incrementAndGet();
ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),false); ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),true);
BufferUtil.clear(buffer); BufferUtil.clear(buffer);
boolean readMore = false; boolean readMore = false;
try try

View File

@ -44,7 +44,7 @@ public class GeneratorParserRoundtripTest
String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF";
ByteBuffer out = bufferPool.acquire(8192,false); ByteBuffer out = bufferPool.acquire(8192,true);
try try
{ {
// Generate Buffer // Generate Buffer
@ -80,7 +80,7 @@ public class GeneratorParserRoundtripTest
String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF";
ByteBuffer out = bufferPool.acquire(8192,false); ByteBuffer out = bufferPool.acquire(8192,true);
try try
{ {
// Setup Frame // Setup Frame

View File

@ -479,7 +479,7 @@ public class BlockheadClient implements IncomingFrames, OutgoingFrames
{ {
LOG.debug("Read: waiting for {} frame(s) from server",expectedCount); LOG.debug("Read: waiting for {} frame(s) from server",expectedCount);
ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false); ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,true);
BufferUtil.clearToFill(buf); BufferUtil.clearToFill(buf);
try try
{ {