Home / Function/ removeBytes() — netty Function Reference

removeBytes() — netty Function Reference

Architecture documentation for the removeBytes() function in ChannelOutboundBuffer.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  0ede732b_f018_f649_0cfa_0293b2b30200["removeBytes()"]
  509b1bc5_7cdc_9ee4_03d9_31eb2203d807["ChannelOutboundBuffer"]
  0ede732b_f018_f649_0cfa_0293b2b30200 -->|defined in| 509b1bc5_7cdc_9ee4_03d9_31eb2203d807
  292a6543_4b71_d410_0730_589bb8ddbf08["progress()"]
  0ede732b_f018_f649_0cfa_0293b2b30200 -->|calls| 292a6543_4b71_d410_0730_589bb8ddbf08
  6dea3e34_a4b3_484d_ed24_d39287511a5a["remove()"]
  0ede732b_f018_f649_0cfa_0293b2b30200 -->|calls| 6dea3e34_a4b3_484d_ed24_d39287511a5a
  99a6a55c_40f3_d958_c218_8834dd310e16["clearNioBuffers()"]
  0ede732b_f018_f649_0cfa_0293b2b30200 -->|calls| 99a6a55c_40f3_d958_c218_8834dd310e16
  style 0ede732b_f018_f649_0cfa_0293b2b30200 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java lines 365–392

    public void removeBytes(long writtenBytes) {
        for (;;) {
            Object msg = current();
            if (!(msg instanceof ByteBuf)) {
                assert writtenBytes == 0;
                break;
            }

            final ByteBuf buf = (ByteBuf) msg;
            final int readerIndex = buf.readerIndex();
            final int readableBytes = buf.writerIndex() - readerIndex;

            if (readableBytes <= writtenBytes) {
                if (writtenBytes != 0) {
                    progress(readableBytes);
                    writtenBytes -= readableBytes;
                }
                remove();
            } else { // readableBytes > writtenBytes
                if (writtenBytes != 0) {
                    buf.readerIndex(readerIndex + (int) writtenBytes);
                    progress(writtenBytes);
                }
                break;
            }
        }
        clearNioBuffers();
    }

Domain

Subdomains

Frequently Asked Questions

What does removeBytes() do?
removeBytes() is a function in the netty codebase, defined in transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java.
Where is removeBytes() defined?
removeBytes() is defined in transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java at line 365.
What does removeBytes() call?
removeBytes() calls 3 function(s): clearNioBuffers, progress, remove.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free