Home / Class/ ChannelFlushPromiseNotifier Class — netty Architecture

ChannelFlushPromiseNotifier Class — netty Architecture

Architecture documentation for the ChannelFlushPromiseNotifier class in ChannelFlushPromiseNotifier.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  179f358e_7c16_a9e3_1d8c_3edd7b9752d0["ChannelFlushPromiseNotifier"]
  70b12992_15ed_37d6_6d32_c69e921cfb0b["ChannelFlushPromiseNotifier.java"]
  179f358e_7c16_a9e3_1d8c_3edd7b9752d0 -->|defined in| 70b12992_15ed_37d6_6d32_c69e921cfb0b
  87cdc914_c182_d9b7_c96f_e738fc2f7f31["ChannelFlushPromiseNotifier()"]
  179f358e_7c16_a9e3_1d8c_3edd7b9752d0 -->|method| 87cdc914_c182_d9b7_c96f_e738fc2f7f31
  7fb8f530_1830_75af_2d22_3f30398e5b49["writeCounter()"]
  179f358e_7c16_a9e3_1d8c_3edd7b9752d0 -->|method| 7fb8f530_1830_75af_2d22_3f30398e5b49
  c36978a2_dad3_4e21_34dc_bc9bd6508250["notifyPromises0()"]
  179f358e_7c16_a9e3_1d8c_3edd7b9752d0 -->|method| c36978a2_dad3_4e21_34dc_bc9bd6508250

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/ChannelFlushPromiseNotifier.java lines 29–273

public final class ChannelFlushPromiseNotifier {

    private long writeCounter;
    private final Queue<FlushCheckpoint> flushCheckpoints = new ArrayDeque<FlushCheckpoint>();
    private final boolean tryNotify;

    /**
     * Create a new instance
     *
     * @param tryNotify if {@code true} the {@link ChannelPromise}s will get notified with
     *                  {@link ChannelPromise#trySuccess()} and {@link ChannelPromise#tryFailure(Throwable)}.
     *                  Otherwise {@link ChannelPromise#setSuccess()} and {@link ChannelPromise#setFailure(Throwable)}
     *                  is used
     */
    public ChannelFlushPromiseNotifier(boolean tryNotify) {
        this.tryNotify = tryNotify;
    }

    /**
     * Create a new instance which will use {@link ChannelPromise#setSuccess()} and
     * {@link ChannelPromise#setFailure(Throwable)} to notify the {@link ChannelPromise}s.
     */
    public ChannelFlushPromiseNotifier() {
        this(false);
    }

    /**
     * @deprecated use {@link #add(ChannelPromise, long)}
     */
    @Deprecated
    public ChannelFlushPromiseNotifier add(ChannelPromise promise, int pendingDataSize) {
        return add(promise, (long) pendingDataSize);
    }

    /**
     * Add a {@link ChannelPromise} to this {@link ChannelFlushPromiseNotifier} which will be notified after the given
     * {@code pendingDataSize} was reached.
     */
    public ChannelFlushPromiseNotifier add(ChannelPromise promise, long pendingDataSize) {
        ObjectUtil.checkNotNull(promise, "promise");
        checkPositiveOrZero(pendingDataSize, "pendingDataSize");
        long checkpoint = writeCounter + pendingDataSize;
        if (promise instanceof FlushCheckpoint) {
            FlushCheckpoint cp = (FlushCheckpoint) promise;
            cp.flushCheckpoint(checkpoint);
            flushCheckpoints.add(cp);
        } else {
            flushCheckpoints.add(new DefaultFlushCheckpoint(checkpoint, promise));
        }
        return this;
    }
    /**
     * Increase the current write counter by the given delta
     */
    public ChannelFlushPromiseNotifier increaseWriteCounter(long delta) {
        checkPositiveOrZero(delta, "delta");
        writeCounter += delta;
        return this;
    }

    /**
     * Return the current write counter of this {@link ChannelFlushPromiseNotifier}
     */
    public long writeCounter() {
        return writeCounter;
    }

    /**
     * Notify all {@link ChannelFuture}s that were registered with {@link #add(ChannelPromise, int)} and
     * their pendingDatasize is smaller after the current writeCounter returned by {@link #writeCounter()}.
     *
     * After a {@link ChannelFuture} was notified it will be removed from this {@link ChannelFlushPromiseNotifier} and
     * so not receive anymore notification.
     */
    public ChannelFlushPromiseNotifier notifyPromises() {
        notifyPromises0(null);
        return this;
    }

    /**
     * @deprecated use {@link #notifyPromises()}

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free