-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
available and releaseByteBuf methods added
Signed-off-by: Maxim Nesen <[email protected]>
- Loading branch information
Showing
1 changed file
with
30 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eeb7d9a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very likely an incorrect implementation of
available
.current.readableBytes()
is not the same asbuffer.remaining()
. (as seen here: eeb7d9a#diff-5e270b08fc2f0e8a5b05af285dd84bbdR149-R151)Don't try so hard. Just check if
buffer
isnull
. If notnull
, returnremaining()
; otherwise, return0
. There is no requirement to be very accurate.For example, why return just the number of
readableBytes
of the first chunk, not all chunks? There is no justification, it is just an estimate.Alternatively, you could maintain an atomic counter of running total of bytes in all byte buffers published (update at the time
publish
is called), and subtract the number of bytes consumed byread
. That would be simple enough. (Although in my opinion an overkill)