Re: [streams] Should we "lock" readable streams while piping? (#241)

- ReadableStream itself has a (private) reader.
- Each of ReadableStream's `.read()`, `.ready` and `.state` calls the corresponding method of ReadableStream's reader.
- `.pipeTo()` and `.getReader()` acquire a lock. They succeed only when ReadableStream' reader is locked. The reader will be released automatically.
- When a reader other than ReadableStream's is released, ReadableStream's reader will be locked again automatically.
- When `.read()` is called through a released reader, it throws.
- When a reader is released, its `.ready` is resolved.
 - It might be good that when closed or errored the promise gets reset, but I'm not sure.
- When a reader is released, its `.state` returns "locked by someone".
 - It might be good that "closed" and "errored" can be seen via an unlocked lock, but I'm not sure.

Makes sense?

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

Received on Friday, 28 November 2014 02:21:17 UTC