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 ofMaxMessagesRecvByteBufAllocator
which respectsChannelConfig.isAutoRead()
and also prevents overflow.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
DefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle
Focuses 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 int
maxMessagesPerRead()
Returns the maximum number of messages to read per read loop.MaxMessagesRecvByteBufAllocator
maxMessagesPerRead(int maxMessagesPerRead)
Sets the maximum number of messages to read per read loop.boolean
respectMaybeMoreData()
Get if future instances ofRecvByteBufAllocator.newHandle()
will stop reading if we think there is no more data.DefaultMaxMessagesRecvByteBufAllocator
respectMaybeMoreData(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:MaxMessagesRecvByteBufAllocator
Returns 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:
maxMessagesPerRead
in interfaceMaxMessagesRecvByteBufAllocator
-
maxMessagesPerRead
public MaxMessagesRecvByteBufAllocator maxMessagesPerRead(int maxMessagesPerRead)
Description copied from interface:MaxMessagesRecvByteBufAllocator
Sets 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:
maxMessagesPerRead
in 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
-true
to 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.false
to 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:
true
to 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.false
to keep reading (up tomaxMessagesPerRead()
) or until there is no data when we attempt to read.
-
-