Class Chunks
java.lang.Object
io.github.mahmoudimus.quic.connection.Chunks
- All Implemented Interfaces:
AutoCloseable
A read in progress on one stream, from
StreamsState.read(io.github.mahmoudimus.quic.connection.StreamId, boolean, io.github.mahmoudimus.quic.connection.Retransmits). Take chunks with next(int), then call close(): flow control credit for the bytes read is issued only
then, so a peer blocked on this stream stays blocked until the reader closes.
Use it with try-with-resources, within one locked section of the connection; it is not thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionlongThe number of bytes read so far.voidclose()Ends the read and issues flow control credit for what was read: MAX_STREAM_DATA, MAX_DATA and, if the stream was released, MAX_STREAMS, queued as needed.next(int maxLength) The next chunk.booleanWhether closing queued a frame that should be sent soon to unblock the peer.
-
Method Details
-
next
The next chunk. In ordered mode chunks follow each other; otherwise their offsets say where they belong.- Parameters:
maxLength- the most bytes to return- Returns:
- the chunk, or null at the end of the stream (the stream is then released)
- Throws:
StreamException-BLOCKEDif no data is available yet,RESETif the peer reset the stream (the stream is then released)IllegalStateException- afterclose()
-
bytesRead
public long bytesRead()The number of bytes read so far.- Returns:
- bytes
-
close
public void close()Ends the read and issues flow control credit for what was read: MAX_STREAM_DATA, MAX_DATA and, if the stream was released, MAX_STREAMS, queued as needed. Repeated calls do nothing.- Specified by:
closein interfaceAutoCloseable
-
shouldTransmit
public boolean shouldTransmit()Whether closing queued a frame that should be sent soon to unblock the peer.- Returns:
- true after
close()queued MAX_DATA, MAX_STREAM_DATA or MAX_STREAMS
-