Add more variants of ByteBufAllocator.ioBuffer() / Update Javadoc

This commit is contained in:
Trustin Lee 2013-03-05 17:59:31 +09:00
parent 8d88acb4a7
commit 4cb023f190
2 changed files with 31 additions and 5 deletions

View File

@ -76,6 +76,22 @@ public abstract class AbstractByteBufAllocator implements ByteBufAllocator {
return heapBuffer(0);
}
@Override
public ByteBuf ioBuffer(int initialCapacity) {
if (PlatformDependent.hasUnsafe()) {
return directBuffer(initialCapacity);
}
return heapBuffer(initialCapacity);
}
@Override
public ByteBuf ioBuffer(int initialCapacity, int maxCapacity) {
if (PlatformDependent.hasUnsafe()) {
return directBuffer(initialCapacity, maxCapacity);
}
return heapBuffer(initialCapacity, maxCapacity);
}
@Override
public ByteBuf heapBuffer() {
return heapBuffer(256, Integer.MAX_VALUE);

View File

@ -40,6 +40,21 @@ public interface ByteBufAllocator {
*/
ByteBuf buffer(int initialCapacity, int maxCapacity);
/**
* Allocate a {@link ByteBuf} whose initial capacity is 0, preferably a direct buffer which is suitable for I/O.
*/
ByteBuf ioBuffer();
/**
* Allocate a {@link ByteBuf}, preferably a direct buffer which is suitable for I/O.
*/
ByteBuf ioBuffer(int initialCapacity);
/**
* Allocate a {@link ByteBuf}, preferably a direct buffer which is suitable for I/O.
*/
ByteBuf ioBuffer(int initialCapacity, int maxCapacity);
/**
* Allocate a heap {@link ByteBuf}.
*/
@ -72,11 +87,6 @@ public interface ByteBufAllocator {
*/
ByteBuf directBuffer(int initialCapacity, int maxCapacity);
/**
* Allocate a {@link ByteBuf} which is used for reading data in from the actual transport.
*/
ByteBuf ioBuffer();
/**
* Allocate a {@link CompositeByteBuf}.
* If it is a direct or heap buffer depends on the actual implementation.