Home / Class/ AbstractCoalescingBufferQueue Class — netty Architecture

AbstractCoalescingBufferQueue Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  ed411aca_4554_3a54_c59f_b4c69a0bca4f["AbstractCoalescingBufferQueue"]
  d89bdfb8_f2af_0519_b446_06bf4570e4bf["AbstractCoalescingBufferQueue.java"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|defined in| d89bdfb8_f2af_0519_b446_06bf4570e4bf
  fef3c623_12e3_cb96_f167_0c6ddbfd9890["AbstractCoalescingBufferQueue()"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|method| fef3c623_12e3_cb96_f167_0c6ddbfd9890
  7a37830c_ea16_4611_3e35_5c64f1ad654a["addFirst()"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|method| 7a37830c_ea16_4611_3e35_5c64f1ad654a
  5aed0cf6_186e_56d0_e3f6_f45fb7f45b4d["add()"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|method| 5aed0cf6_186e_56d0_e3f6_f45fb7f45b4d
  dff5af05_9fa5_b4cb_ec2b_93782e7cf765["ByteBuf()"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|method| dff5af05_9fa5_b4cb_ec2b_93782e7cf765
  40b2d7ee_ab69_691f_b3f0_be44cf83b193["readableBytes()"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|method| 40b2d7ee_ab69_691f_b3f0_be44cf83b193
  0c2b6899_a72a_9fae_a90d_61e1960dfcc0["isEmpty()"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|method| 0c2b6899_a72a_9fae_a90d_61e1960dfcc0
  a624d8ea_7f84_33d8_6acc_616570a23790["releaseAndFailAll()"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|method| a624d8ea_7f84_33d8_6acc_616570a23790
  290d2187_915e_0e58_e2fa_d9e4f68ee2e3["copyTo()"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|method| 290d2187_915e_0e58_e2fa_d9e4f68ee2e3
  467c8c19_eff1_c3a2_43ff_78745ae64293["writeAndRemoveAll()"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|method| 467c8c19_eff1_c3a2_43ff_78745ae64293
  55306b3f_9ca7_f0b7_b035_cf65c1f5511a["String()"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|method| 55306b3f_9ca7_f0b7_b035_cf65c1f5511a
  ba0354a9_5a63_aaf6_6e46_fcdafcdca86c["size()"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|method| ba0354a9_5a63_aaf6_6e46_fcdafcdca86c
  502e490f_81f1_40f2_84f8_f3b570511736["releaseAndCompleteAll()"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|method| 502e490f_81f1_40f2_84f8_f3b570511736
  a5b677d4_5a5b_f770_3ee6_0215e9eac0c4["incrementReadableBytes()"]
  ed411aca_4554_3a54_c59f_b4c69a0bca4f -->|method| a5b677d4_5a5b_f770_3ee6_0215e9eac0c4

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/AbstractCoalescingBufferQueue.java lines 31–432

@UnstableApi
public abstract class AbstractCoalescingBufferQueue {
    private static final InternalLogger logger = InternalLoggerFactory.getInstance(AbstractCoalescingBufferQueue.class);
    private final ArrayDeque<Object> bufAndListenerPairs;
    private final PendingBytesTracker tracker;
    private int readableBytes;

    /**
     * Create a new instance.
     *
     * @param channel the {@link Channel} which will have the {@link Channel#isWritable()} reflect the amount of queued
     *                buffers or {@code null} if there is no writability state updated.
     * @param initSize the initial size of the underlying queue.
     */
    protected AbstractCoalescingBufferQueue(Channel channel, int initSize) {
        bufAndListenerPairs = new ArrayDeque<Object>(initSize);
        tracker = channel == null ? null : PendingBytesTracker.newTracker(channel);
    }

    /**
     * Add a buffer to the front of the queue and associate a promise with it that should be completed when
     * all the buffer's bytes have been consumed from the queue and written.
     * @param buf to add to the head of the queue
     * @param promise to complete when all the bytes have been consumed and written, can be void.
     */
    public final void addFirst(ByteBuf buf, ChannelPromise promise) {
        addFirst(buf, toChannelFutureListener(promise));
    }

    private void addFirst(ByteBuf buf, ChannelFutureListener listener) {
        // Touch the message to make it easier to debug buffer leaks.
        buf.touch();

        if (listener != null) {
            bufAndListenerPairs.addFirst(listener);
        }
        bufAndListenerPairs.addFirst(buf);
        incrementReadableBytes(buf.readableBytes());
    }

    /**
     * Add a buffer to the end of the queue.
     */
    public final void add(ByteBuf buf) {
        add(buf, (ChannelFutureListener) null);
    }

    /**
     * Add a buffer to the end of the queue and associate a promise with it that should be completed when
     * all the buffer's bytes have been consumed from the queue and written.
     * @param buf to add to the tail of the queue
     * @param promise to complete when all the bytes have been consumed and written, can be void.
     */
    public final void add(ByteBuf buf, ChannelPromise promise) {
        // buffers are added before promises so that we naturally 'consume' the entire buffer during removal
        // before we complete it's promise.
        add(buf, toChannelFutureListener(promise));
    }

    /**
     * Add a buffer to the end of the queue and associate a listener with it that should be completed when
     * all the buffers  bytes have been consumed from the queue and written.
     * @param buf to add to the tail of the queue
     * @param listener to notify when all the bytes have been consumed and written, can be {@code null}.
     */
    public final void add(ByteBuf buf, ChannelFutureListener listener) {
        // Touch the message to make it easier to debug buffer leaks.
        buf.touch();

        // buffers are added before promises so that we naturally 'consume' the entire buffer during removal
        // before we complete it's promise.
        bufAndListenerPairs.add(buf);
        if (listener != null) {
            bufAndListenerPairs.add(listener);
        }
        incrementReadableBytes(buf.readableBytes());
    }

    /**
     * Remove the first {@link ByteBuf} from the queue.
     * @param aggregatePromise used to aggregate the promises and listeners for the returned buffer.

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free