Re: [streams] Generalized and precise flow/buffer control (#301)

My current thinking based on discussions this morning:

- pull(enqueue, close, error) becomes pull(enqueue, close, error, spaceLeftGetter) in functionality. (In name and shape, maybe `pull({ enqueue(), close(), error(), desiredSize })`? Can be settled afterward though.)
- Strategies need to be modified to have high water mark directly instead of having flexible shouldApplyBackpressure predicate. (Maybe we allow it to be updated, but unsure by who or how.)
- The when-should-we-call-pull logic stays similar to how it is now, with one addition:
  - After start
  - If queue size changes, up or down, and _either_:
    - spaceLeft = HWM - queueSize > 0, or
    - there are pending reads
  - Promise-debounced

With this change, and a strategy that says HWM = 0, read() will directly correspond to pull(), which is good. (The "if there are pending reads" ensures it.)

With a strategy that has HWM > 0, then pull will be called whenever the queue size is less than the high water mark, and it will be called with spaceLeft (or "desiredSize" maybe) = HWM - current queue size, which allows it to make intelligent decisions about how to generate chunks that it will enqueue.

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

Received on Friday, 20 March 2015 06:40:28 UTC