Home / Function/ readInbound() — netty Function Reference

readInbound() — netty Function Reference

Architecture documentation for the readInbound() function in LocalChannel.java from the netty codebase.

Function java Buffer Search called by 2

Entity Profile

Dependency Diagram

graph TD
  8dea8598_1c1b_dfae_1755_385916268d62["readInbound()"]
  81a44f54_ab3c_5f8b_4522_05c91e5f8eb8["LocalChannel"]
  8dea8598_1c1b_dfae_1755_385916268d62 -->|defined in| 81a44f54_ab3c_5f8b_4522_05c91e5f8eb8
  ca2fb8a0_ef70_093b_b9ef_d1b067cab979["doBeginRead()"]
  ca2fb8a0_ef70_093b_b9ef_d1b067cab979 -->|calls| 8dea8598_1c1b_dfae_1755_385916268d62
  25c4b417_efcc_8ca3_00dc_8ac122d80faf["finishPeerRead0()"]
  25c4b417_efcc_8ca3_00dc_8ac122d80faf -->|calls| 8dea8598_1c1b_dfae_1755_385916268d62
  style 8dea8598_1c1b_dfae_1755_385916268d62 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/local/LocalChannel.java lines 299–335

    private void readInbound() {
        RecvByteBufAllocator.Handle handle = unsafe().recvBufAllocHandle();
        handle.reset(config());
        ChannelPipeline pipeline = pipeline();
        do {
            Object received = inboundBuffer.poll();
            if (received == null) {
                break;
            }
            if (received instanceof ByteBuf && inboundBuffer.peek() instanceof ByteBuf) {
                ByteBuf msg = (ByteBuf) received;
                ByteBuf output = handle.allocate(alloc());
                if (msg.readableBytes() < output.writableBytes()) {
                    // We have an opportunity to coalesce buffers.
                    output.writeBytes(msg, msg.readerIndex(), msg.readableBytes());
                    msg.release();
                    while ((received = inboundBuffer.peek()) instanceof ByteBuf &&
                            ((ByteBuf) received).readableBytes() < output.writableBytes()) {
                        inboundBuffer.poll();
                        msg = (ByteBuf) received;
                        output.writeBytes(msg, msg.readerIndex(), msg.readableBytes());
                        msg.release();
                    }
                    handle.lastBytesRead(output.readableBytes());
                    received = output; // Send the coalesced buffer down the pipeline.
                } else {
                    // It won't be profitable to coalesce buffers this time around.
                    handle.lastBytesRead(output.capacity());
                    output.release();
                }
            }
            handle.incMessagesRead(1);
            pipeline.fireChannelRead(received);
        } while (handle.continueReading());
        handle.readComplete();
        pipeline.fireChannelReadComplete();
    }

Domain

Subdomains

Frequently Asked Questions

What does readInbound() do?
readInbound() is a function in the netty codebase, defined in transport/src/main/java/io/netty/channel/local/LocalChannel.java.
Where is readInbound() defined?
readInbound() is defined in transport/src/main/java/io/netty/channel/local/LocalChannel.java at line 299.
What calls readInbound()?
readInbound() is called by 2 function(s): doBeginRead, finishPeerRead0.

Analyze Your Own Codebase

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

Try Supermodel Free