Package io.netty.channel
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 java.lang.Object implements MaxMessagesRecvByteBufAllocator
Default implementation ofMaxMessagesRecvByteBufAllocatorwhich respectsChannelConfig.isAutoRead()and also prevents overflow.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classDefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandleFocuses on enforcing the maximum messages per read condition forDefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle.continueReading().-
Nested classes/interfaces inherited from interface io.netty.channel.RecvByteBufAllocator
RecvByteBufAllocator.DelegatingHandle, RecvByteBufAllocator.ExtendedHandle, RecvByteBufAllocator.Handle
-
-
Constructor Summary
Constructors Constructor Description DefaultMaxMessagesRecvByteBufAllocator()DefaultMaxMessagesRecvByteBufAllocator(int maxMessagesPerRead)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intmaxMessagesPerRead()Returns the maximum number of messages to read per read loop.MaxMessagesRecvByteBufAllocatormaxMessagesPerRead(int maxMessagesPerRead)Sets the maximum number of messages to read per read loop.booleanrespectMaybeMoreData()Get if future instances ofRecvByteBufAllocator.newHandle()will stop reading if we think there is no more data.DefaultMaxMessagesRecvByteBufAllocatorrespectMaybeMoreData(boolean respectMaybeMoreData)Determine if future instances ofRecvByteBufAllocator.newHandle()will stop reading if we think there is no more data.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.channel.RecvByteBufAllocator
newHandle
-
-
-
-
Method Detail
-
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
public MaxMessagesRecvByteBufAllocator maxMessagesPerRead(int 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
public DefaultMaxMessagesRecvByteBufAllocator respectMaybeMoreData(boolean 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.
-
-