Package io.grpc.netty
Class NettyWritableBufferAllocator
- java.lang.Object
-
- io.grpc.netty.NettyWritableBufferAllocator
-
- All Implemented Interfaces:
WritableBufferAllocator
class NettyWritableBufferAllocator extends java.lang.Object implements WritableBufferAllocator
The default allocator forNettyWritableBuffers used by the Netty transport. We set a minimum bound to avoid unnecessary re-allocation for small follow-on writes and to facilitate Netty's caching of buffer objects for small writes. We set an upper-bound to avoid allocations outside of the arena-pool which are orders of magnitude slower. The Netty transport can receive buffers of arbitrary size and will chunk them based on flow-control so there is no transport requirement for an upper bound.Note: It is assumed that most applications will be using Netty's direct buffer pools for maximum performance.
-
-
Field Summary
Fields Modifier and Type Field Description private io.netty.buffer.ByteBufAllocatorallocatorprivate static intMAX_BUFFERprivate static intMIN_BUFFER
-
Constructor Summary
Constructors Constructor Description NettyWritableBufferAllocator(io.netty.buffer.ByteBufAllocator allocator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WritableBufferallocate(int capacityHint)Request a newWritableBufferwith the givencapacityHint.
-
-
-
Field Detail
-
MIN_BUFFER
private static final int MIN_BUFFER
- See Also:
- Constant Field Values
-
MAX_BUFFER
private static final int MAX_BUFFER
- See Also:
- Constant Field Values
-
allocator
private final io.netty.buffer.ByteBufAllocator allocator
-
-
Method Detail
-
allocate
public WritableBuffer allocate(int capacityHint)
Description copied from interface:WritableBufferAllocatorRequest a newWritableBufferwith the givencapacityHint. The allocator is free to return a buffer with a greater or lesser capacity.- Specified by:
allocatein interfaceWritableBufferAllocator
-
-