QuicSenderStream.
This class maintains a queue of byte buffer containing stream data
that has not yet been packaged for sending. It also keeps track of
the max stream data value.
It acts as a mailbox between a producer (typically a QuicStreamWriter),
and a consumer (typically a jdk.internal.net.http.quic.QuicConnectionImpl ).
This class is abstract: a concrete implementation of this class must only
implement wakeupProducer() and wakeupConsumer() which should
wake up the producer and consumer respectively, when data can be polled or
submitted from the queue.
| Modifier and Type | Field and Description |
|---|---|
| private static final int | BUFFER_SIZE
The amount of data that a StreamWriterQueue is willing to buffer. |
| private volatile long | |
| private volatile long | |
| private ByteBuffer | |
| private final ReentrantLock | |
| private volatile long | |
| private final ConcurrentLinkedQueue | |
| private volatile boolean | |
| private volatile long | |
| private volatile long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public final long | Returns: the amount of produced data which has not been consumed yetReturns the amount of produced data which has not been consumed yet. |
| public final long | Returns: the offset of the data consumed by the consumerReturns the offset of the data consumed by the consumer. |
| public final long | Returns: the offset of the data provided by the producerReturns the offset of the data provided by the producer. |
| pack-priv final void | |
| public final boolean | Returns: whether the producer is blocked due to flow controlWhether the consumer is blocked due to flow control. |
| public final long | |
| protected abstract Logger | |
| public final boolean | Returns: true if the consumer has reached the end of
this stream (equivalent to EOF)Returns |
| public final boolean | Returns: true if the producer has reached the end of
this stream (equivalent to EOF)Returns |
| protected final void | |
| public final void | |
| public final long | Returns: the maximum offset that the peer is prepared to acceptReturns the maximum offset that the peer is prepared to accept. |
| private void | offer(ByteBuffer
the buffer to queue buffer, boolean whether this is the last data for the stream last, boolean whether we should wait for the next submission before
waking up the consumer waitForMore)Queues a buffer in the writing queue. |
| public final ByteBuffer | Returns: aByteBuffer containing at most maxbytes, or null
if no data is available or data is blocked by flow control.the maximum number of bytes the consumer is prepared
to consume. maxbytes)This method is called by the consumer to poll data from the stream queue. |
| public final boolean | Returns: whether the producer is blocked due to full buffersWhether the producer is blocked due to flow control. |
| public final long | |
| public final void | queue(ByteBuffer
a buffer containing data for the stream buffer)This method is called by the producer to queue data to this stream. |
| public final long | Returns: the amount of available data that can be sent with respect to flow control in this streamReturns the amount of available data that can be sent with respect to flow control in this stream. |
| pack-priv final long | Returns: -1 minus the error code that was supplied by the peer when requesting for stop sendingReturns -1 minus the error code that was supplied by the peer when requesting for stop sending. |
| public final long | Returns: the maximum offset that will be accepted by the consumer.the maximum offset that will be accepted by
the consumer data)Updates the flow control credit for this queue. |
| protected final boolean | stopSending(long
the error code errorCode)Called when a stop sending frame is received for this stream |
| protected abstract long | Returns: the stream id this queue was created forReturns the stream id this queue was created for. |
| public final long | Returns: the stream size if known,-1 otherwiseReturns the stream size if known, |
| public final void | submit(ByteBuffer
a buffer containing data for the stream buffer, boolean whether this is the last buffer that will ever be
provided by the provided last)This method is called by the producer to submit data to this stream. |
| protected abstract void | switchState(QuicSenderStream.
the new state - typically dataSentSendingStreamState#DATA_SENTCalled to switch the sending state when data has been sent. |
| protected final void | |
| protected abstract void | wakeupConsumer()
This method is called to wake up the consumer when there is credit and data available for the consumer. |
| protected abstract void | wakeupProducer()
This method is called to wake up the producer when there is credit available for the producer. |
| BUFFER_SIZE | back to summary |
|---|---|
| private static final int BUFFER_SIZE The amount of data that a StreamWriterQueue is willing to buffer. The queue will buffer excess data, but will not wake up the producer until the excess is consumed. | |
| bytesConsumed | back to summary |
|---|---|
| private volatile long bytesConsumed | |
| bytesProduced | back to summary |
|---|---|
| private volatile long bytesProduced | |
| current | back to summary |
|---|---|
| private ByteBuffer current | |
| lock | back to summary |
|---|---|
| private final ReentrantLock lock | |
| maxStreamData | back to summary |
|---|---|
| private volatile long maxStreamData | |
| queue | back to summary |
|---|---|
| private final ConcurrentLinkedQueue<ByteBuffer> queue | |
| resetRequested | back to summary |
|---|---|
| private volatile boolean resetRequested | |
| stopSending | back to summary |
|---|---|
| private volatile long stopSending | |
| streamSize | back to summary |
|---|---|
| private volatile long streamSize | |
| StreamWriterQueue | back to summary |
|---|---|
| pack-priv StreamWriterQueue() | |
| available | back to summary |
|---|---|
| public final long available() Returns the amount of produced data which has not been consumed yet. This is independent of flow control. API Note The returned value is only weakly consistent: it is subject
to race conditions if
| |
| bytesConsumed | back to summary |
|---|---|
| public final long bytesConsumed() Returns the offset of the data consumed by the consumer. API Note The returned value is only weakly consistent: it is subject
to race conditions if
| |
| bytesProduced | back to summary |
|---|---|
| public final long bytesProduced() Returns the offset of the data provided by the producer. API Note The returned value is only weakly consistent: it is subject
to race conditions if
| |
| close | back to summary |
|---|---|
| pack-priv final void close() | |
| consumerBlocked | back to summary |
|---|---|
| public final boolean consumerBlocked() Whether the consumer is blocked due to flow control.
| |
| consumerCredit | back to summary |
|---|---|
| public final long consumerCredit() Returns the credit of the consumer. Implementation Specification This is equivalent to
| |
| debug | back to summary |
|---|---|
| protected abstract Logger debug() | |
| isConsumerDone | back to summary |
|---|---|
| public final boolean isConsumerDone() Returns API Note The returned value is only weakly consistent: it is subject
to race conditions if
| |
| isProducerDone | back to summary |
|---|---|
| public final boolean isProducerDone() Returns API Note The returned value is only weakly consistent: it is subject
to race conditions if
| |
| lock | back to summary |
|---|---|
| protected final void lock() | |
| markReset | back to summary |
|---|---|
| public final void markReset() | |
| maxStreamData | back to summary |
|---|---|
| public final long maxStreamData() Returns the maximum offset that the peer is prepared to accept. API Note The returned value is only weakly consistent: it is subject
to race conditions if
| |
| offer | back to summary |
|---|---|
| private void offer(ByteBuffer buffer, boolean last, boolean waitForMore) throws IOException Queues a buffer in the writing queue.
| |
| poll | back to summary |
|---|---|
| public final ByteBuffer poll(int maxbytes) This method is called by the consumer to poll data from the stream
queue. This method will return a API Note This method increases the consumer offset. It must not be called concurrently by two different threads. Implementation Note If the producer was blocked due to full buffer before this method was called
and the method removes enough of buffered data,
| |
| producerBlocked | back to summary |
|---|---|
| public final boolean producerBlocked() Whether the producer is blocked due to flow control.
| |
| producerCredit | back to summary |
|---|---|
| public final long producerCredit() Returns the credit of the producer. Implementation Specification this is the desired buffer size minus the amount of data already buffered.
| |
| queue | back to summary |
|---|---|
| public final void queue(ByteBuffer buffer) throws IOException This method is called by the producer to queue data to this stream. The producer should not modify the provided buffer after this point. The provided buffer will be queued even if the produced data exceeds the maximum offset that the peer is prepared to accept. API Note The consumer will not be woken, even if enough credit is
available. More data should be submitted using
| |
| readyToSend | back to summary |
|---|---|
| public final long readyToSend() Returns the amount of available data that can be sent with respect to flow control in this stream. . This does not take into account the global connection flow control.
| |
| resetByPeer | back to summary |
|---|---|
| pack-priv final long resetByPeer() Returns -1 minus the error code that was supplied by the peer when requesting for stop sending. API Note a strictly negative value indicates that the stream was reset by the peer. The error code supplied by the peer can be obtained with the formula:
| |
| setMaxStreamData | back to summary |
|---|---|
| public final long setMaxStreamData(long data) Updates the flow control credit for this queue. The maximum offset that will be accepted by the consumer can only increase. Value that are less or equal to the current value of the max stream data are ignored. Implementation Specification If the consumer was blocked due to flow control before
this method was called, and the new value of the max
stream data allows to unblock the consumer, and data
is available,
| |
| stopSending | back to summary |
|---|---|
| protected final boolean stopSending(long errorCode) Called when a stop sending frame is received for this stream
| |
| streamId | back to summary |
|---|---|
| protected abstract long streamId() Returns the stream id this queue was created for.
| |
| streamSize | back to summary |
|---|---|
| public final long streamSize() Returns the stream size if known, API Note The returned value is only weakly consistent: it is subject
to race conditions if
| |
| submit | back to summary |
|---|---|
| public final void submit(ByteBuffer buffer, boolean last) throws IOException This method is called by the producer to submit data to this stream. The producer should not modify the provided buffer after this point. The provided buffer will be queued even if the produced data exceeds the maximum offset that the peer is prepared to accept. API Note If sufficient credit is available, this method will wake up the consumer.
| |
| switchState | back to summary |
|---|---|
| protected abstract void switchState(QuicSenderStream. Called to switch the sending state when data has been sent.
| |
| unlock | back to summary |
|---|---|
| protected final void unlock() | |
| wakeupConsumer | back to summary |
|---|---|
| protected abstract void wakeupConsumer() This method is called to wake up the consumer when there is credit and data available for the consumer. | |
| wakeupProducer | back to summary |
|---|---|
| protected abstract void wakeupProducer() This method is called to wake up the producer when there is credit available for the producer. | |