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 forNettyWritableBuffer
s 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.ByteBufAllocator
allocator
private static int
MAX_BUFFER
private static int
MIN_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 WritableBuffer
allocate(int capacityHint)
Request a newWritableBuffer
with 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:WritableBufferAllocator
Request a newWritableBuffer
with the givencapacityHint
. The allocator is free to return a buffer with a greater or lesser capacity.- Specified by:
allocate
in interfaceWritableBufferAllocator
-
-