Package io.grpc.netty
Class NettyWritableBufferAllocator
java.lang.Object
io.grpc.netty.NettyWritableBufferAllocator
- All Implemented Interfaces:
WritableBufferAllocator
The default allocator for
NettyWritableBuffer
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
FieldsModifier and TypeFieldDescriptionprivate final io.netty.buffer.ByteBufAllocator
private static final int
private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallocate
(int capacityHint) Request a newWritableBuffer
with the givencapacityHint
.
-
Field Details
-
MIN_BUFFER
private static final int MIN_BUFFER- See Also:
-
MAX_BUFFER
private static final int MAX_BUFFER- See Also:
-
allocator
private final io.netty.buffer.ByteBufAllocator allocator
-
-
Constructor Details
-
NettyWritableBufferAllocator
NettyWritableBufferAllocator(io.netty.buffer.ByteBufAllocator allocator)
-
-
Method Details
-
allocate
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
-