Re: [streams] Support reading bytes into buffers allocated by user code on platforms where only async read is available (#253)

Question based on some stuff @yutakahirano I have been discussing. And probably related to the last couple posts, now that I re-read them. Given this scenario:

```js
reader.read(view1).then(...);
reader.read(view2).then(...);
reader.releaseLock();
```

what should happen?

We think `releaseLock()` should throw if there are pending reads. Because, consider how `reader.read(view1)` has started a read in the background thread into `view1`. If we were to let the release succeed, the bytes being read would be skipped by future consumers who get new readers. That seems bad.

GIven that `releaseLock` throws, what else should happen? We have two good alternatives:

- The stream and the reader become errored. This means we don't have to worry about anyone getting bytes that have "skipped ahead" since nobody gets any bytes at all, after you screwed up by trying this.
- Nothing happens: the lock even stays in place. If you in the future wait long enough for the pending read requests to fulfill, you can even do `releaseLock()` again, and it works!

I am leaning toward the latter now that I write them out. But I wanted to record them.

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

Received on Tuesday, 10 March 2015 09:27:34 UTC