Skip to content

Change ChunkedInputStream to not block right after chunk is read#2332

Open
tchaloupka wants to merge 1 commit intovibe-d:masterfrom
tchaloupka:blockedchunkstream
Open

Change ChunkedInputStream to not block right after chunk is read#2332
tchaloupka wants to merge 1 commit intovibe-d:masterfrom
tchaloupka:blockedchunkstream

Conversation

@tchaloupka
Copy link
Contributor

This is probably not an ideal solution but it at least solves my problem - that I need to process chunked stream data right when it arrives and not when the next chunk is available.

@property ulong leastSize() { return bytesInCurrentChunk; }

@property bool dataAvailableForRead() { return m_bytesInCurrentChunk > 0 && m_in.dataAvailableForRead; }
@property bool dataAvailableForRead() { return bytesInCurrentChunk > 0 && m_in.dataAvailableForRead; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must stay as m_bytesInCurrentChunk, so that dataAvailableForRead does not block (its purpose is to be able to tell whether a read will block).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@property bool dataAvailableForRead() { return bytesInCurrentChunk > 0 && m_in.dataAvailableForRead; }
@property bool dataAvailableForRead() { return m_bytesInCurrentChunk > 0 && m_in.dataAvailableForRead; }

@@ -398,11 +399,17 @@ final class ChunkedInputStream : InputStream
readChunk();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably makes sense to take the opportunity and remove this as well, so that the stream is completely lazy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
readChunk();

@Geod24
Copy link
Contributor

Geod24 commented Dec 16, 2020

@tchaloupka Ping

@tchaloupka
Copy link
Contributor Author

I've made the proposed changes.
Sorry for the delay - time flies..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants