Re: [streams] Byte stream update, including reference implementation (#361)

> +  controller._insideUnderlyingByteSource = false;
> +}
> +
> +function CallPullOrPullIntoLaterIfNeeded(controller) {
> +  if (controller._insideUnderlyingByteSource) {
> +    controller._callPullOrPullIntoLaterIfNeeded = true;
> +    return;
> +  }
> +
> +  Promise.resolve().then(CallPullOrPullIntoRepeatedlyIfNeeded.bind(undefined, controller));
> +}
> +
> +function CallPullOrPullIntoRepeatedlyIfNeeded(controller) {
> +  const stream = controller._controlledReadableByteStream;
> +
> +  while (true) {

respond() and enqueue() calls ReadableByteStreamControllerCallPullOrPullIntoLaterIfNeeded() to call pull/pullInto in the next tick if needed. In the cases where pull/pullInto doesn't fulfill all the pending requests, we invoke it again. This allows implementing a pull/pullInto that calls respond()/enqueue() for each pull/pullInto. They'll be called repeatedly and synchronously by this while loop.

I found a bug in ReadableByteStreamControllerCallPullOrPullIntoLaterIfNeeded. Fixed and added tests by bf35ce30e4b1824b684617ad6605748454b66d0a

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/361/files#r33663492

Received on Wednesday, 1 July 2015 09:47:54 UTC