whatwg/streams — pull request #110 by domenic (2014-04-21 07:04:35+00:00)
Title: Transform backpressure approach 2 request for comments

See individual commit messages for details. /cc @othiym23 @tyoshino

The first two commits seem like a good idea to me, independent of their surroundings. Especially the writable one. The readable one is a bit sketchier, since without the next two commits, there's no way for consumers to know that they should be picking up data ASAP.

The next two commits are using the reference implementation + tests to prototype approach 2 from https://github.com/whatwg/streams/issues/24#issuecomment-40911902. Take a look at the tests especially, since those highlight what I'm hoping to accomplish.

The additional internal complexity introduced is sad. But it has some benefits, I think:
- It's hidden from the user
- It paves the way for very similar work as desired by implementers for #97: such off-main-thread-piping would have to manifest very similarly to this kind of piping.
- It was never very great anyway that people could `read()` from a stream that is being piped elsewhere. The API is explicitly designed around single-consumer, with problems occurring if you try to violate that. This revision makes that explicit, by erroring if you try to `read()` from a piped stream.

That said, I still want to explore the solution space here heavily. I'll probably do a branch with approach 5 as well, and I had an idea for approach 4 that I will reiterate back over in that thread.