-
- All Known Implementing Classes:
DefaultMaxMessagesRecvBufferAllocator.MaxMessageHandle
- Enclosing interface:
- RecvBufferAllocator
public static interface RecvBufferAllocator.Handle
-
-
Method Summary
All Methods Instance Methods Abstract 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> maybeMoreDataPredicate)
Same ascontinueReading(boolean)
except "more data" is determined by the supplier parameter.int
guess()
Similar toallocate(BufferAllocator)
except that it does not allocate anything but just tells the capacity.void
incMessagesRead(int numMessages)
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()
Reset any counters that have accumulated and recommend how many messages/bytes should be read for the next read loop.
-
-
-
Method Detail
-
allocate
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.
-
guess
int guess()
Similar toallocate(BufferAllocator)
except that it does not allocate anything but just tells the capacity.
-
reset
void reset()
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.continueReading(boolean)
to determine if the read operation should complete.
-
incMessagesRead
void incMessagesRead(int numMessages)
Increment the number of messages that have been read for the current read loop.- Parameters:
numMessages
- The amount to increment by.
-
lastBytesRead
void lastBytesRead(int bytes)
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.- 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 tolastBytesRead()
. A negative value will signal a termination condition enforced externally to this class and is not required to be enforced incontinueReading(boolean)
.
-
lastBytesRead
int lastBytesRead()
Get the amount of bytes for the previous read operation.- Returns:
- The amount of bytes for the previous read operation.
-
attemptedBytesRead
void attemptedBytesRead(int bytes)
Set how many bytes the read operation will (or did) attempt to read.- Parameters:
bytes
- How many bytes the read operation will (or did) attempt to read.
-
attemptedBytesRead
int attemptedBytesRead()
Get how many bytes the read operation will (or did) attempt to read.- Returns:
- How many bytes the read operation will (or did) attempt to read.
-
continueReading
boolean continueReading(boolean autoRead)
Determine if the current read loop should continue.- 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
boolean continueReading(boolean autoRead, Predicate<RecvBufferAllocator.Handle> maybeMoreDataPredicate)
Same ascontinueReading(boolean)
except "more data" is determined by the supplier parameter.- Parameters:
autoRead
-true
if autoread is used,false
otherwise.maybeMoreDataPredicate
- 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
void readComplete()
The read has completed.
-
-