This commit is contained in:
Trustin Lee 2013-02-21 14:17:04 -08:00
parent 6e73d5471c
commit a9a8d5d8c2

View File

@ -354,6 +354,9 @@ abstract class PoolArena<T> {
static final class DirectArena extends PoolArena<ByteBuffer> { static final class DirectArena extends PoolArena<ByteBuffer> {
private static final boolean USE_UNSAFE_DIRECTBUF =
PlatformDependent.isUnaligned() && PlatformDependent.unsafeHasCopyMethods();
DirectArena(PooledByteBufAllocator parent, int pageSize, int maxOrder, int pageShifts, int chunkSize) { DirectArena(PooledByteBufAllocator parent, int pageSize, int maxOrder, int pageShifts, int chunkSize) {
super(parent, pageSize, maxOrder, pageShifts, chunkSize); super(parent, pageSize, maxOrder, pageShifts, chunkSize);
} }
@ -376,7 +379,7 @@ abstract class PoolArena<T> {
@Override @Override
protected PooledByteBuf<ByteBuffer> newByteBuf(int maxCapacity) { protected PooledByteBuf<ByteBuffer> newByteBuf(int maxCapacity) {
if (PlatformDependent.isUnaligned() && PlatformDependent.unsafeHasCopyMethods()) { if (USE_UNSAFE_DIRECTBUF) {
return new PooledUnsafeDirectByteBuf(maxCapacity); return new PooledUnsafeDirectByteBuf(maxCapacity);
} else { } else {
return new PooledDirectByteBuf(maxCapacity); return new PooledDirectByteBuf(maxCapacity);