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

Source should be permitted to push data onto upstream BufferedInputStream #45

Open
sambitdash opened this issue Aug 18, 2017 · 0 comments

Comments

@sambitdash
Copy link
Contributor

sambitdash commented Aug 18, 2017

The source IO interface today is expected to implement a readbytes! interface. The readbytes! interface is a pull interface. Which essentially means the BufferedInputStream can demand the source the amount of bytes it needs to provide.

Imagine a source like a codec. The source is not aware of the data size till the data is decoded. But the BufferedInputStream request is for a number of bytes that is lesser than the data decoded. In this case, the source needs to maintain its own housekeeping buffer to retain number of bytes. While, this is there in most codec implementations, ideally as a buffer mgmt system BufferedInputStream should be flexible to either request for a size from the source or let the source to request for additional bytes. That way Sources will not have to maintain their own housekeeping with buffers.

One example can be ReadFile call in Windows API, where passing NULL for bytes read will provide the size of the buffer required.

@sambitdash sambitdash changed the title Source should be permitted to push data on to upstream BufferedInputStream Source should be permitted to push data onto upstream BufferedInputStream Aug 18, 2017
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

No branches or pull requests

1 participant