Home / Function/ write0() — netty Function Reference

write0() — netty Function Reference

Architecture documentation for the write0() function in QuicheQuicStreamChannel.java from the netty codebase.

Function java Buffer Allocators calls 2 called by 2

Entity Profile

Dependency Diagram

graph TD
  86200146_0c82_b96d_e3db_5b4ffacfa597["write0()"]
  77188bb7_e7ad_de01_3b54_5bc50b9e2df1["QuicStreamChannelUnsafe"]
  86200146_0c82_b96d_e3db_5b4ffacfa597 -->|defined in| 77188bb7_e7ad_de01_3b54_5bc50b9e2df1
  da5c2828_c8c5_6172_4f45_d61e57ed89ae["writeQueued()"]
  da5c2828_c8c5_6172_4f45_d61e57ed89ae -->|calls| 86200146_0c82_b96d_e3db_5b4ffacfa597
  c225604c_2de8_fe76_73d8_f8ebd8b0d632["writeWithoutCheckChannelState()"]
  c225604c_2de8_fe76_73d8_f8ebd8b0d632 -->|calls| 86200146_0c82_b96d_e3db_5b4ffacfa597
  a249dbfa_942d_d16e_c8eb_e99a04ab68ce["isLocalCreated()"]
  86200146_0c82_b96d_e3db_5b4ffacfa597 -->|calls| a249dbfa_942d_d16e_c8eb_e99a04ab68ce
  d46e3d31_9ac9_1dec_c60f_c3c77a46395a["streamId()"]
  86200146_0c82_b96d_e3db_5b4ffacfa597 -->|calls| d46e3d31_9ac9_1dec_c60f_c3c77a46395a
  style 86200146_0c82_b96d_e3db_5b4ffacfa597 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicStreamChannel.java lines 831–890

        private int write0(Object msg) throws Exception {
            if (type() == QuicStreamType.UNIDIRECTIONAL && !isLocalCreated()) {
                throw new UnsupportedOperationException(
                        "Writes on non-local created streams that are unidirectional are not supported");
            }
            if (finSent) {
                throw new ChannelOutputShutdownException("Fin was sent already");
            }

            final boolean fin;
            ByteBuf buffer;
            if (msg instanceof ByteBuf) {
                fin = false;
                buffer = (ByteBuf) msg;
            } else {
                QuicStreamFrame frame = (QuicStreamFrame) msg;
                fin = frame.hasFin();
                buffer = frame.content();
            }

            boolean readable = buffer.isReadable();
            if (!fin && !readable) {
                return 1;
            }

            boolean sendSomething = false;
            try {
                do {
                    int res = parent().streamSend(streamId(), buffer, fin);

                    // Update the capacity as well.
                    long cap = parent.streamCapacity(streamId());
                    if (cap >= 0) {
                        capacity = cap;
                    }
                    if (res < 0) {
                        return res;
                    }
                    if (readable && res == 0) {
                        return 0;
                    }
                    sendSomething = true;
                    buffer.skipBytes(res);
                } while (buffer.isReadable());

                if (fin) {
                    finSent = true;
                    outputShutdown = true;
                }
                return 1;
            } finally {
                // As we called quiche_conn_stream_send(...) we need to ensure we will call quiche_conn_send(...) either
                // now or we will do so once we see the channelReadComplete event.
                //
                // See https://docs.rs/quiche/0.6.0/quiche/struct.Connection.html#method.send
                if (sendSomething) {
                    parent.connectionSendAndFlush();
                }
            }
        }

Domain

Subdomains

Frequently Asked Questions

What does write0() do?
write0() is a function in the netty codebase, defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicStreamChannel.java.
Where is write0() defined?
write0() is defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicStreamChannel.java at line 831.
What does write0() call?
write0() calls 2 function(s): isLocalCreated, streamId.
What calls write0()?
write0() is called by 2 function(s): writeQueued, writeWithoutCheckChannelState.

Analyze Your Own Codebase

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

Try Supermodel Free