Home / Class/ HandleImpl Class — netty Architecture

HandleImpl Class — netty Architecture

Architecture documentation for the HandleImpl class in DefaultMaxBytesRecvByteBufAllocator.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  410f1c17_73e1_5fa8_7547_955af2229cf5["HandleImpl"]
  a07ae128_e91d_b91d_d244_c168b2593fa8["DefaultMaxBytesRecvByteBufAllocator.java"]
  410f1c17_73e1_5fa8_7547_955af2229cf5 -->|defined in| a07ae128_e91d_b91d_d244_c168b2593fa8
  63f452f5_dc21_b520_c2c3_677bf309aee8["ByteBuf()"]
  410f1c17_73e1_5fa8_7547_955af2229cf5 -->|method| 63f452f5_dc21_b520_c2c3_677bf309aee8
  a3cb6d05_8f85_9cca_f557_d2e88f25ef1f["guess()"]
  410f1c17_73e1_5fa8_7547_955af2229cf5 -->|method| a3cb6d05_8f85_9cca_f557_d2e88f25ef1f
  96f3d531_b135_229b_1c7c_d69c01701d90["reset()"]
  410f1c17_73e1_5fa8_7547_955af2229cf5 -->|method| 96f3d531_b135_229b_1c7c_d69c01701d90
  2e0c306a_e6fc_a387_29dd_47b626eee99c["incMessagesRead()"]
  410f1c17_73e1_5fa8_7547_955af2229cf5 -->|method| 2e0c306a_e6fc_a387_29dd_47b626eee99c
  d669f233_74d2_ef76_ccf1_ffe90d3c18f5["lastBytesRead()"]
  410f1c17_73e1_5fa8_7547_955af2229cf5 -->|method| d669f233_74d2_ef76_ccf1_ffe90d3c18f5
  4d4227c4_485c_77b9_c730_d4d0a2189a03["continueReading()"]
  410f1c17_73e1_5fa8_7547_955af2229cf5 -->|method| 4d4227c4_485c_77b9_c730_d4d0a2189a03
  fdafaf55_5234_b25d_eeda_126fab8096ba["readComplete()"]
  410f1c17_73e1_5fa8_7547_955af2229cf5 -->|method| fdafaf55_5234_b25d_eeda_126fab8096ba
  e454a6ef_37bd_f571_70ce_c1db4a2e654a["attemptedBytesRead()"]
  410f1c17_73e1_5fa8_7547_955af2229cf5 -->|method| e454a6ef_37bd_f571_70ce_c1db4a2e654a

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/DefaultMaxBytesRecvByteBufAllocator.java lines 35–104

    private final class HandleImpl implements ExtendedHandle {
        private int individualReadMax;
        private int bytesToRead;
        private int lastBytesRead;
        private int attemptBytesRead;
        private final UncheckedBooleanSupplier defaultMaybeMoreSupplier = new UncheckedBooleanSupplier() {
            @Override
            public boolean get() {
                return attemptBytesRead == lastBytesRead;
            }
        };

        @Override
        public ByteBuf allocate(ByteBufAllocator alloc) {
            return alloc.ioBuffer(guess());
        }

        @Override
        public int guess() {
            return Math.min(individualReadMax, bytesToRead);
        }

        @Override
        public void reset(ChannelConfig config) {
            bytesToRead = maxBytesPerRead();
            individualReadMax = maxBytesPerIndividualRead();
        }

        @Override
        public void incMessagesRead(int amt) {
        }

        @Override
        public void lastBytesRead(int bytes) {
            lastBytesRead = bytes;
            // Ignore if bytes is negative, the interface contract states it will be detected externally after call.
            // The value may be "invalid" after this point, but it doesn't matter because reading will be stopped.
            bytesToRead -= bytes;
        }

        @Override
        public int lastBytesRead() {
            return lastBytesRead;
        }

        @Override
        public boolean continueReading() {
            return continueReading(defaultMaybeMoreSupplier);
        }

        @Override
        public boolean continueReading(UncheckedBooleanSupplier maybeMoreDataSupplier) {
            // Keep reading if we are allowed to read more bytes, and our last read filled up the buffer we provided.
            return bytesToRead > 0 && maybeMoreDataSupplier.get();
        }

        @Override
        public void readComplete() {
        }

        @Override
        public void attemptedBytesRead(int bytes) {
            attemptBytesRead = bytes;
        }

        @Override
        public int attemptedBytesRead() {
            return attemptBytesRead;
        }
    }

Frequently Asked Questions

What is the HandleImpl class?
HandleImpl is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/DefaultMaxBytesRecvByteBufAllocator.java.
Where is HandleImpl defined?
HandleImpl is defined in transport/src/main/java/io/netty/channel/DefaultMaxBytesRecvByteBufAllocator.java at line 35.

Analyze Your Own Codebase

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

Try Supermodel Free