Package io.netty.channel
Class DefaultMaxBytesRecvByteBufAllocator.HandleImpl
java.lang.Object
io.netty.channel.DefaultMaxBytesRecvByteBufAllocator.HandleImpl
- All Implemented Interfaces:
RecvByteBufAllocator.ExtendedHandle
,RecvByteBufAllocator.Handle
- Enclosing class:
DefaultMaxBytesRecvByteBufAllocator
private final class DefaultMaxBytesRecvByteBufAllocator.HandleImpl
extends Object
implements RecvByteBufAllocator.ExtendedHandle
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private int
private final UncheckedBooleanSupplier
private int
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallocate
(ByteBufAllocator 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
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
Determine if the current read loop should continue.boolean
continueReading
(UncheckedBooleanSupplier maybeMoreDataSupplier) Same asRecvByteBufAllocator.Handle.continueReading()
except "more data" is determined by the supplier parameter.int
guess()
Similar toRecvByteBufAllocator.Handle.allocate(ByteBufAllocator)
except that it does not allocate anything but just tells the capacity.void
incMessagesRead
(int amt) Increment the number of messages that have been read for the current read loop.int
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
The read has completed.void
reset
(ChannelConfig config) Reset any counters that have accumulated and recommend how many messages/bytes should be read for the next read loop.
-
Field Details
-
individualReadMax
private int individualReadMax -
bytesToRead
private int bytesToRead -
lastBytesRead
private int lastBytesRead -
attemptBytesRead
private int attemptBytesRead -
defaultMaybeMoreSupplier
-
-
Constructor Details
-
HandleImpl
private HandleImpl()
-
-
Method Details
-
allocate
Description copied from interface:RecvByteBufAllocator.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 interfaceRecvByteBufAllocator.Handle
-
guess
public int guess()Description copied from interface:RecvByteBufAllocator.Handle
Similar toRecvByteBufAllocator.Handle.allocate(ByteBufAllocator)
except that it does not allocate anything but just tells the capacity.- Specified by:
guess
in interfaceRecvByteBufAllocator.Handle
-
reset
Description copied from interface:RecvByteBufAllocator.Handle
Reset any counters that have accumulated and recommend how many messages/bytes should be read for the next read loop.This may be used by
This is only ever a hint and may be ignored by the implementation.RecvByteBufAllocator.Handle.continueReading()
to determine if the read operation should complete.- Specified by:
reset
in interfaceRecvByteBufAllocator.Handle
- Parameters:
config
- The channel configuration which may impact this object's behavior.
-
incMessagesRead
public void incMessagesRead(int amt) Description copied from interface:RecvByteBufAllocator.Handle
Increment the number of messages that have been read for the current read loop.- Specified by:
incMessagesRead
in interfaceRecvByteBufAllocator.Handle
- Parameters:
amt
- The amount to increment by.
-
lastBytesRead
public void lastBytesRead(int bytes) Description copied from interface:RecvByteBufAllocator.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 interfaceRecvByteBufAllocator.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 toRecvByteBufAllocator.Handle.lastBytesRead()
. A negative value will signal a termination condition enforced externally to this class and is not required to be enforced inRecvByteBufAllocator.Handle.continueReading()
.
-
lastBytesRead
public int lastBytesRead()Description copied from interface:RecvByteBufAllocator.Handle
Get the amount of bytes for the previous read operation.- Specified by:
lastBytesRead
in interfaceRecvByteBufAllocator.Handle
- Returns:
- The amount of bytes for the previous read operation.
-
continueReading
public boolean continueReading()Description copied from interface:RecvByteBufAllocator.Handle
Determine if the current read loop should continue.- Specified by:
continueReading
in interfaceRecvByteBufAllocator.Handle
- Returns:
true
if the read loop should continue reading.false
if the read loop is complete.
-
continueReading
Description copied from interface:RecvByteBufAllocator.ExtendedHandle
Same asRecvByteBufAllocator.Handle.continueReading()
except "more data" is determined by the supplier parameter.- Specified by:
continueReading
in interfaceRecvByteBufAllocator.ExtendedHandle
- Parameters:
maybeMoreDataSupplier
- A supplier that determines if there maybe more data to read.
-
readComplete
public void readComplete()Description copied from interface:RecvByteBufAllocator.Handle
The read has completed.- Specified by:
readComplete
in interfaceRecvByteBufAllocator.Handle
-
attemptedBytesRead
public void attemptedBytesRead(int bytes) Description copied from interface:RecvByteBufAllocator.Handle
Set how many bytes the read operation will (or did) attempt to read.- Specified by:
attemptedBytesRead
in interfaceRecvByteBufAllocator.Handle
- Parameters:
bytes
- How many bytes the read operation will (or did) attempt to read.
-
attemptedBytesRead
public int attemptedBytesRead()Description copied from interface:RecvByteBufAllocator.Handle
Get how many bytes the read operation will (or did) attempt to read.- Specified by:
attemptedBytesRead
in interfaceRecvByteBufAllocator.Handle
- Returns:
- How many bytes the read operation will (or did) attempt to read.
-