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

ReadableByteStream: pull + pullInto or just pullInto #363

Closed
tyoshino opened this issue Jun 16, 2015 · 3 comments
Closed

ReadableByteStream: pull + pullInto or just pullInto #363

tyoshino opened this issue Jun 16, 2015 · 3 comments

Comments

@tyoshino
Copy link
Member

Branched from #295 (comment)

Write the reason if we choose to have both.

@domenic
Copy link
Member

domenic commented Jun 16, 2015

At some point the plan was that if you do getReader().read(), it will pre-allocate a buffer for you of a given size, then pass that to pullInto. The size could be determined by an option to the constructor (maybe part of the strategy? or maybe part of the underlying byte source object).

That plan is definitely less powerful than having both pull and pullInto. But maybe it gives a significant enough simplification to be worth it? I am not sure.

@tyoshino
Copy link
Member Author

Oh, right. I remembered that. But, that said, this problem is connected with #329. If the ReadableByteStream is designed to automatically allocate a buffer for reader.read() call, and if we implement an underlying byte source that may be able to pass an allocated buffer with its ownership to us (for example the identity transform being discussed in the issue), we want to pass through the buffer to the consumer. So, yes, it should be more powerful to leave the work to allocate a buffer up to the underlying source.

@tyoshino
Copy link
Member Author

Current ReadableByteStream being redesigned at #418 has both pull and pullInto. When read(view) is called, via pullInto, the stream passes the TypedArray received from the consumer to the underlying source. For read(), pull is invoked and the underlying byte source allocates a TypedArray and enqueue()-s it. Allocation is now done by the underlying source.

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

No branches or pull requests

2 participants