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 Object
implements MaxMessagesRecvByteBufAllocator
Default implementation of
MaxMessagesRecvByteBufAllocator
which respects ChannelConfig.isAutoRead()
and also prevents overflow.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private int
private boolean
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultMaxMessagesRecvByteBufAllocator
(int maxMessagesPerRead) DefaultMaxMessagesRecvByteBufAllocator
(int maxMessagesPerRead, boolean ignoreBytesRead) -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the maximum number of messages to read per read loop.maxMessagesPerRead
(int maxMessagesPerRead) Sets the maximum number of messages to read per read loop.final boolean
Get 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.RecvByteBufAllocator
newHandle
-
Field Details
-
ignoreBytesRead
private final boolean ignoreBytesRead -
maxMessagesPerRead
private volatile int maxMessagesPerRead -
respectMaybeMoreData
private volatile boolean respectMaybeMoreData
-
-
Constructor Details
-
DefaultMaxMessagesRecvByteBufAllocator
public DefaultMaxMessagesRecvByteBufAllocator() -
DefaultMaxMessagesRecvByteBufAllocator
public DefaultMaxMessagesRecvByteBufAllocator(int maxMessagesPerRead) -
DefaultMaxMessagesRecvByteBufAllocator
DefaultMaxMessagesRecvByteBufAllocator(int maxMessagesPerRead, boolean ignoreBytesRead)
-
-
Method Details
-
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
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
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.
-