Home / Class/ WriteResumptionListener Class — netty Architecture

WriteResumptionListener Class — netty Architecture

Architecture documentation for the WriteResumptionListener class in Http3FrameCodec.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  95db0354_1de2_6bba_62f7_7920b9ac9012["WriteResumptionListener"]
  50e04e81_eb2c_8eef_5e05_95116fe8e65f["Http3FrameCodec.java"]
  95db0354_1de2_6bba_62f7_7920b9ac9012 -->|defined in| 50e04e81_eb2c_8eef_5e05_95116fe8e65f
  dd72d950_ebf9_c941_6665_ad64352b4200["WriteResumptionListener()"]
  95db0354_1de2_6bba_62f7_7920b9ac9012 -->|method| dd72d950_ebf9_c941_6665_ad64352b4200
  4433feb1_9179_606e_bfc6_7cb187b0948d["operationComplete()"]
  95db0354_1de2_6bba_62f7_7920b9ac9012 -->|method| 4433feb1_9179_606e_bfc6_7cb187b0948d
  516fac3d_3045_d842_66ce_3e1f0af8e1c8["enqueue()"]
  95db0354_1de2_6bba_62f7_7920b9ac9012 -->|method| 516fac3d_3045_d842_66ce_3e1f0af8e1c8
  d68aa8f4_493d_68c4_8cde_28dbc391490b["enqueueFlush()"]
  95db0354_1de2_6bba_62f7_7920b9ac9012 -->|method| d68aa8f4_493d_68c4_8cde_28dbc391490b
  5fe8b6a4_8a83_021e_73f5_eec914124c9b["drain()"]
  95db0354_1de2_6bba_62f7_7920b9ac9012 -->|method| 5fe8b6a4_8a83_021e_73f5_eec914124c9b

Relationship Graph

Source Code

codec-http3/src/main/java/io/netty/handler/codec/http3/Http3FrameCodec.java lines 740–803

    private static final class WriteResumptionListener
            implements GenericFutureListener<Future<? super QuicStreamChannel>> {
        private static final Object FLUSH = new Object();
        private final PendingWriteQueue queue;
        private final ChannelHandlerContext ctx;
        private final Http3FrameCodec codec;

        private WriteResumptionListener(ChannelHandlerContext ctx, Http3FrameCodec codec) {
            this.ctx = ctx;
            this.codec = codec;
            queue = new PendingWriteQueue(ctx);
        }

        @Override
        public void operationComplete(Future<? super QuicStreamChannel> future) {
            drain();
        }

        void enqueue(Object msg, ChannelPromise promise) {
            assert ctx.channel().eventLoop().inEventLoop();
            // Touch the message to allow easier debugging of memory leaks
            ReferenceCountUtil.touch(msg);
            queue.add(msg, promise);
        }

        void enqueueFlush() {
            assert ctx.channel().eventLoop().inEventLoop();
            queue.add(FLUSH, ctx.voidPromise());
        }

        void drain() {
            assert ctx.channel().eventLoop().inEventLoop();
            boolean flushSeen = false;
            try {
                for (;;) {
                    Object entry = queue.current();
                    if (entry == null) {
                        break;
                    }
                    if (entry == FLUSH) {
                        flushSeen = true;
                        queue.remove().trySuccess();
                    } else {
                        // Retain the entry as remove() will call release() as well.
                        codec.write0(ctx, ReferenceCountUtil.retain(entry), queue.remove());
                    }
                }
                // indicate that writes do not need to be enqueued. As we are on the eventloop, no other writes can
                // happen while we are draining, hence we would not write out of order.
                codec.writeResumptionListener = null;
            } finally {
                if (flushSeen) {
                    codec.flush(ctx);
                }
            }
        }

        static WriteResumptionListener newListener(ChannelHandlerContext ctx, Http3FrameCodec codec) {
            WriteResumptionListener listener = new WriteResumptionListener(ctx, codec);
            assert codec.qpackAttributes != null;
            codec.qpackAttributes.whenEncoderStreamAvailable(listener);
            return listener;
        }
    }

Frequently Asked Questions

What is the WriteResumptionListener class?
WriteResumptionListener is a class in the netty codebase, defined in codec-http3/src/main/java/io/netty/handler/codec/http3/Http3FrameCodec.java.
Where is WriteResumptionListener defined?
WriteResumptionListener is defined in codec-http3/src/main/java/io/netty/handler/codec/http3/Http3FrameCodec.java at line 740.

Analyze Your Own Codebase

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

Try Supermodel Free