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

public abstract Class QuicStreamWriter

extends Object
Class Inheritance
Known Direct Subclasses
jdk.internal.net.http.http3.streams.QueuingStreamPair.QueuingWriter, jdk.internal.net.http.quic.streams.QuicSenderStreamImpl.QuicStreamWriterImpl
Imports
java.io.IOException, java.nio.ByteBuffer, jdk.internal.net.http.common.SequentialScheduler, jdk.internal.net.http.quic.frames.StreamFrame, jdk.internal.net.http.quic.streams.QuicSenderStream.SendingStreamState

An abstract class to model a writer plugged into a QuicStream to which data can be written. The data is wrapped in StreamFrame before being written.

Field Summary

Modifier and TypeField and Description
pack-priv final SequentialScheduler

Constructor Summary

AccessConstructor and Description
public
QuicStreamWriter(SequentialScheduler
A sequential scheduler that will push data into this writer.
scheduler
)

Creates a new instance of a QuicStreamWriter.

Method Summary

Modifier and TypeMethod and Description
public abstract boolean

Returns:

true if this writer is connected to its stream
connected
()

Returns true if this writer is connected to its stream.

public abstract long
credit()

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

public abstract void
queueForWriting(ByteBuffer
A byte buffer to schedule for writing
buffer
)

Queues a ByteBuffer on the writing queue for this stream.

public abstract void
reset(long
the application error code
errorCode
)

Abruptly resets the stream.

public abstract void
scheduleForWriting(ByteBuffer
A byte buffer to schedule for writing
buffer
,
boolean
Whether that's the last data that will be sent through this stream.
last
)

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

public abstract QuicSenderStream.SendingStreamState

Returns:

the sending state of the stream
sendingState
()

Returns the sending state of the stream.

public boolean

Returns:

true if STOP_SENDING was received
stopSendingReceived
()

Returns true if STOP_SENDING was received.

public abstract QuicSenderStream

Returns:

the stream this writer is connected to, or null if this writer isn't currently connected
stream
()

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

schedulerback to summary
pack-priv final SequentialScheduler scheduler

Constructor Detail

QuicStreamWriterback to summary
public QuicStreamWriter(SequentialScheduler scheduler)

Creates a new instance of a QuicStreamWriter.

Parameters
scheduler:SequentialScheduler

A sequential scheduler that will push data into this writer.

Method Detail

connectedback to summary
public abstract boolean connected()

Returns true if this writer is connected to its stream.

Returns:boolean

true if this writer is connected to its stream

See Also
QuicSenderStream#connectWriter(SequentialScheduler), QuicSenderStream#disconnectWriter(QuicStreamWriter)
creditback to summary
public abstract long 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).

API Note

This information is used to avoid buffering too much data while waiting for flow credit on the underlying stream. When flow credit is available, the scheduler loop is invoked to resume writing. The scheduler can then call this method to figure out how much data to request from upstream.

Exceptions
IllegalStateException:
if this writer is no longer connected to its stream
queueForWritingback to summary
public abstract void queueForWriting(ByteBuffer buffer) throws IOException

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.

API Note

Use this method as a hint that more data will be upcoming shortly that might be aggregated with the data being queued in order to reduce the number of packets that will be sent to the peer. This is useful when a small number of bytes need to be written to the stream before actual stream data. Typically, this can be used for writing the HTTP/3 stream type for a unidirectional HTTP/3 stream before starting to send stream data.

Parameters
buffer:ByteBuffer

A byte buffer to schedule for writing

Exceptions
IOException:
if the state of the stream isn't SendingStreamState#READY or SendingStreamState#SEND
IllegalStateException:
if this writer is no longer connected to its stream
resetback to summary
public abstract void reset(long errorCode) throws IOException

Abruptly resets the stream.

Parameters
errorCode:long

the application error code

Exceptions
IllegalStateException:
if this writer is no longer connected to its stream
scheduleForWritingback to summary
public abstract void scheduleForWriting(ByteBuffer buffer, boolean last) throws IOException

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.

Parameters
buffer:ByteBuffer

A byte buffer to schedule for writing

last:boolean

Whether that's the last data that will be sent through this stream.

Exceptions
IOException:
if the state of the stream isn't SendingStreamState#READY or SendingStreamState#SEND
IllegalStateException:
if this writer is no longer connected to its stream
sendingStateback to summary
public abstract QuicSenderStream.SendingStreamState sendingState()

Returns the sending state of the stream.

API Note

This method returns the state of the QuicSenderStream to which this writer is connected.

Returns:QuicSenderStream.SendingStreamState

the sending state of the stream

Exceptions
IllegalStateException:
if this writer is no longer connected to its stream
stopSendingReceivedback to summary
public boolean stopSendingReceived()

Returns true if STOP_SENDING was received.

Returns:boolean

true if STOP_SENDING was received

streamback to summary
public abstract QuicSenderStream stream()

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

Returns:QuicSenderStream

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