Re: [streams] Finalize pull/pullInto behavior (#423)

> This basically means, once a pull happens, you keep doing pull until desiredSize = 0? And, once a pullInto happens, you keep doing pullInto until .... when?

We keep doing pull if some operation that suggests running pull again happens inside that pull.

For example,
```
pull() {
  controller.enqueue(x);
}
```

Currently, in the ReadableStream with non-byte source, EnqueueInReadableStreamController() does that. It sets pullAgain, and in the pullPromise handler, ReadableStreamControllerCallPullIfNeeded() is ran again. ReadableStream with byte source does this by using a while loop.

If any operation (which suggests running pull/pullInto again) doesn't occur inside a pull/pullInto invocation, we stop the loop.

For example, when stream.read(view) is invoked and view is a Uint32Array,

```
pullInto(<view>);
// enqueue() was called with 1 byte. Call pullInto again to notify that more data is needed
pullInto(<view with new region (the 1st byte was filled)>);
// enqueue() was called with 1 byte. One more.
pullInto(<view with new region (2 bytes has been filled)>);
// Nothing happened this time. Stop running pull() and wait for the source to generate more data
```


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

Received on Monday, 18 January 2016 13:00:03 UTC