private final class DefaultHttp2RemoteFlowController.FlowState extends java.lang.Object implements StreamByteDistributor.StreamState
Modifier and Type | Field and Description |
---|---|
private boolean |
cancelled
Set to true if cancel() was called.
|
private BooleanSupplier |
isWritableSupplier |
private boolean |
markedWritable |
private int |
pendingBytes |
private java.util.Deque<Http2RemoteFlowController.FlowControlled> |
pendingWriteQueue |
private Http2Stream |
stream |
private int |
window |
private boolean |
writing
Set to true while a frame is being written, false otherwise.
|
Constructor and Description |
---|
FlowState(Http2Stream stream) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
cancel()
Any operations that may be pending are cleared and the status of these operations is failed.
|
private void |
cancel(java.lang.Throwable cause)
Clears the pending queue and writes errors for each remaining frame.
|
private void |
decrementFlowControlWindow(int bytes)
Decrement the per stream and connection flow control window by
bytes . |
private void |
decrementPendingBytes(int bytes,
boolean updateStreamableBytes)
If this frame is in the pending queue, decrements the number of pending bytes for the stream.
|
(package private) void |
enqueueFrame(Http2RemoteFlowController.FlowControlled frame)
Adds the
frame to the pending queue and increments the pending byte count. |
private void |
enqueueFrameWithoutMerge(Http2RemoteFlowController.FlowControlled frame) |
boolean |
hasFrame()
Indicates whether or not there are frames pending for this stream.
|
private void |
incrementPendingBytes(int numBytes,
boolean updateStreamableBytes)
Increments the number of pending bytes for this node and optionally updates the
StreamByteDistributor . |
(package private) int |
incrementStreamWindow(int delta)
Increments the flow control window for this stream by the given delta and returns the new value.
|
(package private) boolean |
isWritable()
Determine if the stream associated with this object is writable.
|
(package private) boolean |
markedWritability()
Returns the parameter from the last call to
markedWritability(boolean) . |
(package private) void |
markedWritability(boolean isWritable)
Save the state of writability.
|
private Http2RemoteFlowController.FlowControlled |
peek()
Returns the the head of the pending queue, or
null if empty. |
int |
pendingBytes()
Get the amount of bytes this stream has pending to send.
|
Http2Stream |
stream()
The stream this state is associated with.
|
int |
windowSize()
The size (in bytes) of the stream's flow control window.
|
(package private) void |
windowSize(int initialWindowSize)
Reset the window size for this stream.
|
private int |
writableWindow()
Returns the maximum writable window (minimum of the stream and connection windows).
|
(package private) int |
writeAllocatedBytes(int allocated)
Write the allocated bytes for this stream.
|
private void |
writeError(Http2RemoteFlowController.FlowControlled frame,
Http2Exception cause)
Discards this
FlowControlled , writing an error. |
private final Http2Stream stream
private final java.util.Deque<Http2RemoteFlowController.FlowControlled> pendingWriteQueue
private int window
private int pendingBytes
private boolean markedWritable
private boolean writing
private boolean cancelled
private BooleanSupplier isWritableSupplier
FlowState(Http2Stream stream)
boolean isWritable()
true
if the stream associated with this object is writable.public Http2Stream stream()
stream
in interface StreamByteDistributor.StreamState
boolean markedWritability()
markedWritability(boolean)
.void markedWritability(boolean isWritable)
public int windowSize()
StreamByteDistributor.StreamState
A StreamByteDistributor
needs to know the stream's window size in order to avoid allocating bytes
if the window size is negative. The window size being 0
may also be significant to determine when if
an stream has been given a chance to write an empty frame, and also enables optimizations like not writing
empty frames in some situations (don't write headers until data can also be written).
windowSize
in interface StreamByteDistributor.StreamState
Http2CodecUtil#streamableBytes(StreamState)
void windowSize(int initialWindowSize)
int writeAllocatedBytes(int allocated)
-1
if no write occurred.int incrementStreamWindow(int delta) throws Http2Exception
Http2Exception
private int writableWindow()
public int pendingBytes()
StreamByteDistributor.StreamState
StreamByteDistributor.StreamState.windowSize()
!pendingBytes
in interface StreamByteDistributor.StreamState
Http2CodecUtil#streamableBytes(StreamState)
void enqueueFrame(Http2RemoteFlowController.FlowControlled frame)
frame
to the pending queue and increments the pending byte count.private void enqueueFrameWithoutMerge(Http2RemoteFlowController.FlowControlled frame)
public boolean hasFrame()
StreamByteDistributor.StreamState
hasFrame
in interface StreamByteDistributor.StreamState
private Http2RemoteFlowController.FlowControlled peek()
null
if empty.void cancel()
private void cancel(java.lang.Throwable cause)
cause
- the Throwable
that caused this method to be invoked.private void incrementPendingBytes(int numBytes, boolean updateStreamableBytes)
StreamByteDistributor
.private void decrementPendingBytes(int bytes, boolean updateStreamableBytes)
private void decrementFlowControlWindow(int bytes)
bytes
.private void writeError(Http2RemoteFlowController.FlowControlled frame, Http2Exception cause)
FlowControlled
, writing an error. If this frame is in the pending queue,
the unwritten bytes are removed from this branch of the priority tree.