Module io.netty5.transport
Package io.netty5.channel
Class DefaultMaxMessagesRecvBufferAllocator.MaxMessageHandle
- java.lang.Object
-
- io.netty5.channel.DefaultMaxMessagesRecvBufferAllocator.MaxMessageHandle
-
- All Implemented Interfaces:
RecvBufferAllocator.Handle
- Enclosing class:
- DefaultMaxMessagesRecvBufferAllocator
public abstract class DefaultMaxMessagesRecvBufferAllocator.MaxMessageHandle extends Object implements RecvBufferAllocator.Handle
Focuses on enforcing the maximum messages per read condition forcontinueReading(boolean)
.
-
-
Constructor Summary
Constructors Constructor Description MaxMessageHandle()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Buffer
allocate(BufferAllocator alloc)
Creates a new receive buffer whose capacity is probably large enough to read all inbound data and small enough not to waste its space.int
attemptedBytesRead()
Get how many bytes the read operation will (or did) attempt to read.void
attemptedBytesRead(int bytes)
Set how many bytes the read operation will (or did) attempt to read.boolean
continueReading(boolean autoRead)
Determine if the current read loop should continue.boolean
continueReading(boolean autoRead, Predicate<RecvBufferAllocator.Handle> maybeMoreDataSupplier)
Same asRecvBufferAllocator.Handle.continueReading(boolean)
except "more data" is determined by the supplier parameter.void
incMessagesRead(int amt)
Increment the number of messages that have been read for the current read loop.int
lastBytesRead()
Get the amount of bytes for the previous read operation.void
lastBytesRead(int bytes)
Set the bytes that have been read for the last read operation.void
readComplete()
The read has completed.void
reset()
OnlyChannelOption.MAX_MESSAGES_PER_READ
is used.protected int
totalBytesRead()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.RecvBufferAllocator.Handle
guess
-
-
-
-
Method Detail
-
reset
public void reset()
OnlyChannelOption.MAX_MESSAGES_PER_READ
is used.- Specified by:
reset
in interfaceRecvBufferAllocator.Handle
-
allocate
public Buffer allocate(BufferAllocator alloc)
Description copied from interface:RecvBufferAllocator.Handle
Creates a new receive buffer whose capacity is probably large enough to read all inbound data and small enough not to waste its space.- Specified by:
allocate
in interfaceRecvBufferAllocator.Handle
-
incMessagesRead
public final void incMessagesRead(int amt)
Description copied from interface:RecvBufferAllocator.Handle
Increment the number of messages that have been read for the current read loop.- Specified by:
incMessagesRead
in interfaceRecvBufferAllocator.Handle
- Parameters:
amt
- The amount to increment by.
-
lastBytesRead
public void lastBytesRead(int bytes)
Description copied from interface:RecvBufferAllocator.Handle
Set the bytes that have been read for the last read operation. This may be used to increment the number of bytes that have been read.- Specified by:
lastBytesRead
in interfaceRecvBufferAllocator.Handle
- Parameters:
bytes
- The number of bytes from the previous read operation. This may be negative if an read error occurs. If a negative value is seen it is expected to be return on the next call toRecvBufferAllocator.Handle.lastBytesRead()
. A negative value will signal a termination condition enforced externally to this class and is not required to be enforced inRecvBufferAllocator.Handle.continueReading(boolean)
.
-
lastBytesRead
public final int lastBytesRead()
Description copied from interface:RecvBufferAllocator.Handle
Get the amount of bytes for the previous read operation.- Specified by:
lastBytesRead
in interfaceRecvBufferAllocator.Handle
- Returns:
- The amount of bytes for the previous read operation.
-
continueReading
public boolean continueReading(boolean autoRead)
Description copied from interface:RecvBufferAllocator.Handle
Determine if the current read loop should continue.- Specified by:
continueReading
in interfaceRecvBufferAllocator.Handle
- Parameters:
autoRead
- if autoread is used,false
otherwise.- Returns:
true
if the read loop should continue reading.false
if the read loop is complete.
-
continueReading
public boolean continueReading(boolean autoRead, Predicate<RecvBufferAllocator.Handle> maybeMoreDataSupplier)
Description copied from interface:RecvBufferAllocator.Handle
Same asRecvBufferAllocator.Handle.continueReading(boolean)
except "more data" is determined by the supplier parameter.- Specified by:
continueReading
in interfaceRecvBufferAllocator.Handle
- Parameters:
autoRead
-true
if autoread is used,false
otherwise.maybeMoreDataSupplier
- A Predicate that determines if there maybe more data to read.- Returns:
true
if the read loop should continue reading.false
if the read loop is complete.
-
readComplete
public void readComplete()
Description copied from interface:RecvBufferAllocator.Handle
The read has completed.- Specified by:
readComplete
in interfaceRecvBufferAllocator.Handle
-
attemptedBytesRead
public int attemptedBytesRead()
Description copied from interface:RecvBufferAllocator.Handle
Get how many bytes the read operation will (or did) attempt to read.- Specified by:
attemptedBytesRead
in interfaceRecvBufferAllocator.Handle
- Returns:
- How many bytes the read operation will (or did) attempt to read.
-
attemptedBytesRead
public void attemptedBytesRead(int bytes)
Description copied from interface:RecvBufferAllocator.Handle
Set how many bytes the read operation will (or did) attempt to read.- Specified by:
attemptedBytesRead
in interfaceRecvBufferAllocator.Handle
- Parameters:
bytes
- How many bytes the read operation will (or did) attempt to read.
-
totalBytesRead
protected final int totalBytesRead()
-
-