Home / Function/ notifyPromises0() — netty Function Reference

notifyPromises0() — netty Function Reference

Architecture documentation for the notifyPromises0() function in ChannelFlushPromiseNotifier.java from the netty codebase.

Function java Buffer Telemetry calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  c36978a2_dad3_4e21_34dc_bc9bd6508250["notifyPromises0()"]
  179f358e_7c16_a9e3_1d8c_3edd7b9752d0["ChannelFlushPromiseNotifier"]
  c36978a2_dad3_4e21_34dc_bc9bd6508250 -->|defined in| 179f358e_7c16_a9e3_1d8c_3edd7b9752d0
  87cdc914_c182_d9b7_c96f_e738fc2f7f31["ChannelFlushPromiseNotifier()"]
  87cdc914_c182_d9b7_c96f_e738fc2f7f31 -->|calls| c36978a2_dad3_4e21_34dc_bc9bd6508250
  d267af4b_9032_e31a_9ece_e1dad7a68a6d["flushCheckpoint()"]
  c36978a2_dad3_4e21_34dc_bc9bd6508250 -->|calls| d267af4b_9032_e31a_9ece_e1dad7a68a6d
  style c36978a2_dad3_4e21_34dc_bc9bd6508250 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/ChannelFlushPromiseNotifier.java lines 191–241

    private void notifyPromises0(Throwable cause) {
        if (flushCheckpoints.isEmpty()) {
            writeCounter = 0;
            return;
        }

        final long writeCounter = this.writeCounter;
        for (;;) {
            FlushCheckpoint cp = flushCheckpoints.peek();
            if (cp == null) {
                // Reset the counter if there's nothing in the notification list.
                this.writeCounter = 0;
                break;
            }

            if (cp.flushCheckpoint() > writeCounter) {
                if (writeCounter > 0 && flushCheckpoints.size() == 1) {
                    this.writeCounter = 0;
                    cp.flushCheckpoint(cp.flushCheckpoint() - writeCounter);
                }
                break;
            }

            flushCheckpoints.remove();
            ChannelPromise promise = cp.promise();
            if (cause == null) {
                if (tryNotify) {
                    promise.trySuccess();
                } else {
                    promise.setSuccess();
                }
            } else {
                if (tryNotify) {
                    promise.tryFailure(cause);
                } else {
                    promise.setFailure(cause);
                }
            }
        }

        // Avoid overflow
        final long newWriteCounter = this.writeCounter;
        if (newWriteCounter >= 0x8000000000L) {
            // Reset the counter only when the counter grew pretty large
            // so that we can reduce the cost of updating all entries in the notification list.
            this.writeCounter = 0;
            for (FlushCheckpoint cp: flushCheckpoints) {
                cp.flushCheckpoint(cp.flushCheckpoint() - newWriteCounter);
            }
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does notifyPromises0() do?
notifyPromises0() is a function in the netty codebase, defined in transport/src/main/java/io/netty/channel/ChannelFlushPromiseNotifier.java.
Where is notifyPromises0() defined?
notifyPromises0() is defined in transport/src/main/java/io/netty/channel/ChannelFlushPromiseNotifier.java at line 191.
What does notifyPromises0() call?
notifyPromises0() calls 1 function(s): flushCheckpoint.
What calls notifyPromises0()?
notifyPromises0() is called by 1 function(s): ChannelFlushPromiseNotifier.

Analyze Your Own Codebase

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

Try Supermodel Free