Use direct byte buffers instead of normal ones in niowrapper

This commit is contained in:
Matt Corallo 2013-07-09 16:36:15 +02:00 committed by Mike Hearn
parent e6965d0217
commit 2061d28e52
2 changed files with 2 additions and 2 deletions

View file

@ -53,7 +53,7 @@ public class ProtobufClient extends MessageWriteTarget {
final int connectTimeoutMillis) throws IOException { final int connectTimeoutMillis) throws IOException {
// Try to fit at least one message in the network buffer, but place an upper and lower limit on its size to make // Try to fit at least one message in the network buffer, but place an upper and lower limit on its size to make
// sure it doesnt get too large or have to call read too often. // sure it doesnt get too large or have to call read too often.
dbuf = ByteBuffer.allocate(Math.min(Math.max(parser.maxMessageSize, BUFFER_SIZE_LOWER_BOUND), BUFFER_SIZE_UPPER_BOUND)); dbuf = ByteBuffer.allocateDirect(Math.min(Math.max(parser.maxMessageSize, BUFFER_SIZE_LOWER_BOUND), BUFFER_SIZE_UPPER_BOUND));
parser.setWriteTarget(this); parser.setWriteTarget(this);
sc = SocketChannel.open(); sc = SocketChannel.open();

View file

@ -64,7 +64,7 @@ public class ProtobufServer {
throw new IOException("Parser factory.getNewParser returned null"); throw new IOException("Parser factory.getNewParser returned null");
} }
this.parser = newParser; this.parser = newParser;
dbuf = ByteBuffer.allocate(Math.min(Math.max(newParser.maxMessageSize, BUFFER_SIZE_LOWER_BOUND), BUFFER_SIZE_UPPER_BOUND)); dbuf = ByteBuffer.allocateDirect(Math.min(Math.max(newParser.maxMessageSize, BUFFER_SIZE_LOWER_BOUND), BUFFER_SIZE_UPPER_BOUND));
newParser.setWriteTarget(this); newParser.setWriteTarget(this);
} }