APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.net.http.http3.streams

public Class QueuingStreamPair

extends UniStreamPair
Class Inheritance
Imports
java.io.IOException, java.nio.Buffer, .ByteBuffer, java.util.concurrent.ConcurrentLinkedQueue, java.util.function.Consumer, jdk.internal.net.http.common.Logger, jdk.internal.net.http.http3.streams.Http3Streams.StreamType, jdk.internal.net.http.quic.QuicConnection, jdk.internal.net.http.quic.streams.QuicSenderStream, .QuicSenderStream.SendingStreamState, .QuicStreamReader, .QuicStreamWriter

A class that models a pair of unidirectional streams, where data to be written is simply submitted to a queue.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
QueuingStreamPair.QueuingWriter

A class that wraps the actual QuicStreamWriter and redirect everything to the QueuingStreamPair's writerQueue - so that data is not sent out of order.

Field Summary

Modifier and TypeField and Description
protected final ConcurrentLinkedQueue<ByteBuffer>
Inherited from jdk.internal.net.http.http3.streams.UniStreamPair:
debugerrorHandlerpeerReaderpeerReadScheduler

Constructor Summary

AccessConstructor and Description
public
QueuingStreamPair(Http3Streams.StreamType
the HTTP/3 stream type
streamType
,
QuicConnection
the underlying Quic connection
quicConnection
,
Consumer<ByteBuffer>
the receiver callback
receiver
,
UniStreamPair.StreamErrorHandler
the error handler invoked in case of read errors
errorHandler
,
Logger
the debug logger
logger
)

Creates a new QueuingStreamPair for the given HTTP/3 streamType.

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

the available credit, taking into account data that has not been submitted yet
credit
()

Returns the available credit, taking into account data that has not been submitted yet.

pack-priv void
localWriterLoop()

Overrides jdk.internal.net.http.http3.streams.UniStreamPair.localWriterLoop.

This method is overridden by QueuingStreamPair to implement a writer loop for this stream.

public final void
submitData(ByteBuffer
the data to submit
buffer
)

Submit data to be written to the sending stream via this object's internal queue.

pack-priv QuicStreamWriter
wrap(QuicStreamWriter writer)

Overrides jdk.internal.net.http.http3.streams.UniStreamPair.wrap.

Used by subclasses to redirect queuing of data to the subclass queue.

Inherited from jdk.internal.net.http.http3.streams.UniStreamPair:
futureReceiverStreamfutureReceiverStreamReaderfutureSenderStreamfutureSenderStreamWriterlocalStreamTypelocalWriterlocalWriteSchedulerremoteStreamTypestopSchedulers

Field Detail

writerQueueback to summary
protected final ConcurrentLinkedQueue<ByteBuffer> writerQueue

Constructor Detail

QueuingStreamPairback to summary
public QueuingStreamPair(Http3Streams.StreamType streamType, QuicConnection quicConnection, Consumer<ByteBuffer> receiver, UniStreamPair.StreamErrorHandler errorHandler, Logger logger)

Creates a new QueuingStreamPair for the given HTTP/3 streamType. Valid values for streamType are StreamType#CONTROL, StreamType#QPACK_ENCODER, and StreamType#QPACK_DECODER.

This class implements a read loop and a write loop.

The read loop will call the given receiver whenever a ByteBuffer is received.

Data can be written to the stream simply by submitting it to the internal unbounded queue managed by this stream. When the stream becomes writable, the write loop is invoked and all pending data in the queue is written to the stream, until the stream is blocked or the queue is empty.

Parameters
streamType:Http3Streams.StreamType

the HTTP/3 stream type

quicConnection:QuicConnection

the underlying Quic connection

receiver:Consumer<ByteBuffer>

the receiver callback

errorHandler:UniStreamPair.StreamErrorHandler

the error handler invoked in case of read errors

logger:Logger

the debug logger

Method Detail

creditback to summary
public long credit()

Returns the available credit, taking into account data that has not been submitted yet. This is only weakly consistent.

Returns:long

the available credit, taking into account data that has not been submitted yet

localWriterLoopback to summary
pack-priv void localWriterLoop()

Overrides jdk.internal.net.http.http3.streams.UniStreamPair.localWriterLoop.

Doc from jdk.internal.net.http.http3.streams.UniStreamPair.localWriterLoop.

This method is overridden by QueuingStreamPair to implement a writer loop for this stream. It is only called when the concrete subclass is QueuingStreamPair.

Annotations
@Override
submitDataback to summary
public final void submitData(ByteBuffer buffer)

Submit data to be written to the sending stream via this object's internal queue.

Parameters
buffer:ByteBuffer

the data to submit

wrapback to summary
pack-priv QuicStreamWriter wrap(QuicStreamWriter writer)

Overrides jdk.internal.net.http.http3.streams.UniStreamPair.wrap.

Doc from jdk.internal.net.http.http3.streams.UniStreamPair.wrap.

Used by subclasses to redirect queuing of data to the subclass queue.

Annotations
@Override
jdk.internal.net.http.http3.streams back to summary

pack-priv Class QueuingStreamPair.QueuingWriter

extends QuicStreamWriter
Class Inheritance

A class that wraps the actual QuicStreamWriter and redirect everything to the QueuingStreamPair's writerQueue - so that data is not sent out of order.

Field Summary

Modifier and TypeField and Description
pack-priv final QuicStreamWriter

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
connected()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.connected.

Returns true if this writer is connected to its stream.

public long
credit()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.credit.

Indicates how many bytes the writer is prepared to received for sending.

public void
queueForWriting(ByteBuffer buffer)

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.queueForWriting.

Queues a ByteBuffer on the writing queue for this stream.

public void
reset(long errorCode)

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.reset.

Abruptly resets the stream.

public void
scheduleForWriting(ByteBuffer buffer, boolean last)

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.scheduleForWriting.

Pushes a ByteBuffer to be scheduled for writing on the stream.

public QuicSenderStream.SendingStreamState
sendingState()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.sendingState.

Returns the sending state of the stream.

public QuicSenderStream
stream()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.stream.

Returns the stream this writer is connected to, or null if this writer isn't currently connected.

Inherited from jdk.internal.net.http.quic.streams.QuicStreamWriter:
stopSendingReceived

Field Detail

writerback to summary
pack-priv final QuicStreamWriter writer

Constructor Detail

QueuingWriterback to summary
pack-priv QueuingWriter(QuicStreamWriter writer)

Method Detail

connectedback to summary
public boolean connected()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.connected.

Doc from jdk.internal.net.http.quic.streams.QuicStreamWriter.connected.

Returns true if this writer is connected to its stream.

Annotations
@Override
creditback to summary
public long credit()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.credit.

Doc from jdk.internal.net.http.quic.streams.QuicStreamWriter.credit.

Indicates how many bytes the writer is prepared to received for sending. When that value grows from 0, and if the queue has no pending data, the scheduler is triggered to elicit more calls to scheduleForWriting(ByteBuffer, boolean).

Annotations
@Override
queueForWritingback to summary
public void queueForWriting(ByteBuffer buffer) throws IOException

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.queueForWriting.

Doc from jdk.internal.net.http.quic.streams.QuicStreamWriter.queueForWriting.

Queues a ByteBuffer on the writing queue for this stream. The consumer will not be woken up. More data should be submitted using scheduleForWriting(ByteBuffer, boolean) in order to wake the consumer.

Annotations
@Override
Exceptions
IOException:
if the state of the stream isn't SendingStreamState#READY or SendingStreamState#SEND
resetback to summary
public void reset(long errorCode) throws IOException

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.reset.

Doc from jdk.internal.net.http.quic.streams.QuicStreamWriter.reset.

Abruptly resets the stream.

Annotations
@Override
scheduleForWritingback to summary
public void scheduleForWriting(ByteBuffer buffer, boolean last) throws IOException

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.scheduleForWriting.

Doc from jdk.internal.net.http.quic.streams.QuicStreamWriter.scheduleForWriting.

Pushes a ByteBuffer to be scheduled for writing on the stream. The ByteBuffer will be wrapped in a StreamFrame before being sent. Data that cannot be sent due to a lack of flow credit will be buffered.

Annotations
@Override
Exceptions
IOException:
if the state of the stream isn't SendingStreamState#READY or SendingStreamState#SEND
sendingStateback to summary
public QuicSenderStream.SendingStreamState sendingState()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.sendingState.

Doc from jdk.internal.net.http.quic.streams.QuicStreamWriter.sendingState.

Returns the sending state of the stream.

Annotations
@Override
streamback to summary
public QuicSenderStream stream()

Implements abstract jdk.internal.net.http.quic.streams.QuicStreamWriter.stream.

Doc from jdk.internal.net.http.quic.streams.QuicStreamWriter.stream.

Returns the stream this writer is connected to, or null if this writer isn't currently connected.

Annotations
@Override