Add more variants of ByteBufAllocator.ioBuffer() / Update Javadoc
This commit is contained in:
parent
8d88acb4a7
commit
4cb023f190
@ -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);
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user