Re: [streams] Byte streams: write up design rationales and vision for how they are used/what they enable (#177)

I'd like to prototype the unified byte stream underlying source idea we discussed today.

- `ReadableByteStream` has a queue `[[queue]]`
- If the `[[queue]]` is not empty, `autoReader.read()` gets fulfilled with the `ArrayBufferView` at the top of the `[[queue]]`
- If the `[[queue]]` is empty, `autoReader.read()` gets queued in the `[[pendingReads]]` queue
- `source.pull()` is called to notify that a new `read()` is made on the `autoReader`
- `source` calls `delegate.enqueue()` to enqueue an `ArrayBufferView` to the `[[queue]]`
- If the `[[queue]]` is not empty, `byobReader.read(view)`, `view` gets filled with bytes on the `ArrayBufferView`s in the `[[queue]]`. If the bytes are not sufficient to fill up `view` fully, `source.read(newView)` is called where `newView` specifies the not yet filled region
- If the `[[queue]]` is empty, `byobReader.read(view)` calls `source.read(view)`
- `source.read(view)` may be called in a row
- `pull()` is not called after `source.read(view)` until `source` fulfills the `source.read(view)`. This is guaranteed by the requirement that a byob reader cannot be released until the pending reads are all fulfilled
- `source.read(view)` is fulfilled by calling `delegate.done()`. Not `delegate.enqueue()`.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/177#issuecomment-83984473

Received on Friday, 20 March 2015 10:47:08 UTC