Class DefaultMaxMessagesRecvByteBufAllocator
java.lang.Object
io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator
- All Implemented Interfaces:
MaxMessagesRecvByteBufAllocator, RecvByteBufAllocator
- Direct Known Subclasses:
AdaptiveRecvByteBufAllocator, FixedRecvByteBufAllocator, ServerChannelRecvByteBufAllocator
public abstract class DefaultMaxMessagesRecvByteBufAllocator
extends Object
implements MaxMessagesRecvByteBufAllocator
Default implementation of
MaxMessagesRecvByteBufAllocator which respects ChannelConfig.isAutoRead()
and also prevents overflow.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassFocuses on enforcing the maximum messages per read condition forDefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle.continueReading().Nested classes/interfaces inherited from interface RecvByteBufAllocator
RecvByteBufAllocator.DelegatingHandle, RecvByteBufAllocator.ExtendedHandle, RecvByteBufAllocator.Handle -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the maximum number of messages to read per read loop. achannelRead()event.maxMessagesPerRead(int maxMessagesPerRead) Sets the maximum number of messages to read per read loop.final booleanGet if future instances ofRecvByteBufAllocator.newHandle()will stop reading if we think there is no more data.respectMaybeMoreData(boolean respectMaybeMoreData) Determine if future instances ofRecvByteBufAllocator.newHandle()will stop reading if we think there is no more data.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface RecvByteBufAllocator
newHandle
-
Constructor Details
-
DefaultMaxMessagesRecvByteBufAllocator
public DefaultMaxMessagesRecvByteBufAllocator() -
DefaultMaxMessagesRecvByteBufAllocator
public DefaultMaxMessagesRecvByteBufAllocator(int maxMessagesPerRead)
-
-
Method Details
-
maxMessagesPerRead
public int maxMessagesPerRead()Description copied from interface:MaxMessagesRecvByteBufAllocatorReturns the maximum number of messages to read per read loop. achannelRead()event. If this value is greater than 1, an event loop might attempt to read multiple times to procure multiple messages.- Specified by:
maxMessagesPerReadin interfaceMaxMessagesRecvByteBufAllocator
-
maxMessagesPerRead
Description copied from interface:MaxMessagesRecvByteBufAllocatorSets the maximum number of messages to read per read loop. If this value is greater than 1, an event loop might attempt to read multiple times to procure multiple messages.- Specified by:
maxMessagesPerReadin interfaceMaxMessagesRecvByteBufAllocator
-
respectMaybeMoreData
Determine if future instances ofRecvByteBufAllocator.newHandle()will stop reading if we think there is no more data.- Parameters:
respectMaybeMoreData-trueto stop reading if we think there is no more data. This may save a system call to read from the socket, but if data has arrived in a racy fashion we may give up ourmaxMessagesPerRead()quantum and have to wait for the selector to notify us of more data.falseto keep reading (up tomaxMessagesPerRead()) or until there is no data when we attempt to read.
- Returns:
this.
-
respectMaybeMoreData
public final boolean respectMaybeMoreData()Get if future instances ofRecvByteBufAllocator.newHandle()will stop reading if we think there is no more data.- Returns:
trueto stop reading if we think there is no more data. This may save a system call to read from the socket, but if data has arrived in a racy fashion we may give up ourmaxMessagesPerRead()quantum and have to wait for the selector to notify us of more data.falseto keep reading (up tomaxMessagesPerRead()) or until there is no data when we attempt to read.
-