Package io.netty.buffer
Class AbstractByteBufAllocator
java.lang.Object
io.netty.buffer.AbstractByteBufAllocator
- All Implemented Interfaces:
ByteBufAllocator
- Direct Known Subclasses:
PooledByteBufAllocator,UnpooledByteBufAllocator
Skeletal
ByteBufAllocator implementation to extend.-
Field Summary
Fields inherited from interface io.netty.buffer.ByteBufAllocator
DEFAULT -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstance use heap buffers by defaultprotectedAbstractByteBufAllocator(boolean preferDirect) Create new instance -
Method Summary
Modifier and TypeMethodDescriptionbuffer()Allocate aByteBuf.buffer(int initialCapacity) Allocate aByteBufwith the given initial capacity.buffer(int initialCapacity, int maxCapacity) Allocate aByteBufwith the given initial capacity and the given maximal capacity.intcalculateNewCapacity(int minNewCapacity, int maxCapacity) Allocate aCompositeByteBuf.compositeBuffer(int maxNumComponents) Allocate aCompositeByteBufwith the given maximum number of components that can be stored in it.Allocate a directCompositeByteBuf.compositeDirectBuffer(int maxNumComponents) Allocate a directCompositeByteBufwith the given maximum number of components that can be stored in it.Allocate a heapCompositeByteBuf.compositeHeapBuffer(int maxNumComponents) Allocate a heapCompositeByteBufwith the given maximum number of components that can be stored in it.Allocate a directByteBuf.directBuffer(int initialCapacity) Allocate a directByteBufwith the given initial capacity.directBuffer(int initialCapacity, int maxCapacity) Allocate a directByteBufwith the given initial capacity and the given maximal capacity.Allocate a heapByteBuf.heapBuffer(int initialCapacity) Allocate a heapByteBufwith the given initial capacity.heapBuffer(int initialCapacity, int maxCapacity) Allocate a heapByteBufwith the given initial capacity and the given maximal capacity.ioBuffer()Allocate aByteBuf, preferably a direct buffer which is suitable for I/O.ioBuffer(int initialCapacity) Allocate aByteBuf, preferably a direct buffer which is suitable for I/O.ioBuffer(int initialCapacity, int maxCapacity) Allocate aByteBuf, preferably a direct buffer which is suitable for I/O.protected abstract ByteBufnewDirectBuffer(int initialCapacity, int maxCapacity) Create a directByteBufwith the given initialCapacity and maxCapacity.protected abstract ByteBufnewHeapBuffer(int initialCapacity, int maxCapacity) Create a heapByteBufwith the given initialCapacity and maxCapacity.protected static ByteBuftoLeakAwareBuffer(ByteBuf buf) protected static CompositeByteBuftoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.netty.buffer.ByteBufAllocator
isDirectBufferPooled
-
Constructor Details
-
AbstractByteBufAllocator
protected AbstractByteBufAllocator()Instance use heap buffers by default -
AbstractByteBufAllocator
protected AbstractByteBufAllocator(boolean preferDirect) Create new instance- Parameters:
preferDirect-trueifbuffer(int)should try to allocate a direct buffer rather than a heap buffer
-
-
Method Details
-
toLeakAwareBuffer
-
toLeakAwareBuffer
-
buffer
Description copied from interface:ByteBufAllocatorAllocate aByteBuf. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
bufferin interfaceByteBufAllocator
-
buffer
Description copied from interface:ByteBufAllocatorAllocate aByteBufwith the given initial capacity. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
bufferin interfaceByteBufAllocator
-
buffer
Description copied from interface:ByteBufAllocatorAllocate aByteBufwith the given initial capacity and the given maximal capacity. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
bufferin interfaceByteBufAllocator
-
ioBuffer
Description copied from interface:ByteBufAllocatorAllocate aByteBuf, preferably a direct buffer which is suitable for I/O.- Specified by:
ioBufferin interfaceByteBufAllocator
-
ioBuffer
Description copied from interface:ByteBufAllocatorAllocate aByteBuf, preferably a direct buffer which is suitable for I/O.- Specified by:
ioBufferin interfaceByteBufAllocator
-
ioBuffer
Description copied from interface:ByteBufAllocatorAllocate aByteBuf, preferably a direct buffer which is suitable for I/O.- Specified by:
ioBufferin interfaceByteBufAllocator
-
heapBuffer
Description copied from interface:ByteBufAllocatorAllocate a heapByteBuf.- Specified by:
heapBufferin interfaceByteBufAllocator
-
heapBuffer
Description copied from interface:ByteBufAllocatorAllocate a heapByteBufwith the given initial capacity.- Specified by:
heapBufferin interfaceByteBufAllocator
-
heapBuffer
Description copied from interface:ByteBufAllocatorAllocate a heapByteBufwith the given initial capacity and the given maximal capacity.- Specified by:
heapBufferin interfaceByteBufAllocator
-
directBuffer
Description copied from interface:ByteBufAllocatorAllocate a directByteBuf.- Specified by:
directBufferin interfaceByteBufAllocator
-
directBuffer
Description copied from interface:ByteBufAllocatorAllocate a directByteBufwith the given initial capacity.- Specified by:
directBufferin interfaceByteBufAllocator
-
directBuffer
Description copied from interface:ByteBufAllocatorAllocate a directByteBufwith the given initial capacity and the given maximal capacity.- Specified by:
directBufferin interfaceByteBufAllocator
-
compositeBuffer
Description copied from interface:ByteBufAllocatorAllocate aCompositeByteBuf. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
compositeBufferin interfaceByteBufAllocator
-
compositeBuffer
Description copied from interface:ByteBufAllocatorAllocate aCompositeByteBufwith the given maximum number of components that can be stored in it. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
compositeBufferin interfaceByteBufAllocator
-
compositeHeapBuffer
Description copied from interface:ByteBufAllocatorAllocate a heapCompositeByteBuf.- Specified by:
compositeHeapBufferin interfaceByteBufAllocator
-
compositeHeapBuffer
Description copied from interface:ByteBufAllocatorAllocate a heapCompositeByteBufwith the given maximum number of components that can be stored in it.- Specified by:
compositeHeapBufferin interfaceByteBufAllocator
-
compositeDirectBuffer
Description copied from interface:ByteBufAllocatorAllocate a directCompositeByteBuf.- Specified by:
compositeDirectBufferin interfaceByteBufAllocator
-
compositeDirectBuffer
Description copied from interface:ByteBufAllocatorAllocate a directCompositeByteBufwith the given maximum number of components that can be stored in it.- Specified by:
compositeDirectBufferin interfaceByteBufAllocator
-
newHeapBuffer
Create a heapByteBufwith the given initialCapacity and maxCapacity. -
newDirectBuffer
Create a directByteBufwith the given initialCapacity and maxCapacity. -
toString
-
calculateNewCapacity
public int calculateNewCapacity(int minNewCapacity, int maxCapacity) Description copied from interface:ByteBufAllocatorCalculate the new capacity of aByteBufthat is used when aByteBufneeds to expand by theminNewCapacitywithmaxCapacityas upper-bound.- Specified by:
calculateNewCapacityin interfaceByteBufAllocator
-