Re: [streams] Move stuff into controller to make RS and RBS closer (#418)

Awesome, thanks so much for working on this.

So the readers are still owned by the stream? That is probably good, and simpler than what I was originally thinking of.

Let me try to write a summary to help get my head around it. I will use ReadableStream since it is simpler.

ReadableStream has:
  - state, reader, storedError, disturbed, and controller internal slots
  - AddReadRequestToReadableStream, GetNumReadRequests, RespondToReadRequest "spec internal methods" to allow the controller to manipulate its controlled readable stream (and its reader) without manipulating internal state directly.

ReadableStreamController has:
  - controlledReadableStream, underlyingSource, strategySize, strategyHWM, queue, started, closeRequested, pulling, pullAgain internal slots.
  - CancelReadableStreamController, EnqueueInReadableStreamController, ErrorReadableStreamController, GetReadableStreamControllerDesiredSize, ReadableStreamControllerCallPullIfNeeded, ShouldPullReadableStreamController "spec internal methods".

The eventual path forward, then, would be:

- Convert ReadableStreamController's spec-internal methods into actual internal "methods", probably written something like `ReadableStreamController@[[Cancel]](...)`. In source code we can name these `_Close()` and have them be methods in the class, which will be nice.
- Match up all controller internal methods so that both ReadableStreamController and ReadableByteStreamController have the same set of internal methods.
- Convert ReadableStream to call `this@[[controller]]@[[Cancel]](...)`, thus getting polymorphism for when we allow constructing ReadableStreams with ReadableByteStreamControllers, and merging the two classes.

This sounds like it will work really well. There are probably some more complexities for the controller <-> reader interaction, but what you have so far makes sense.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/418#issuecomment-165598765

Received on Thursday, 17 December 2015 22:26:16 UTC