Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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 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.

None yet

3 participants