-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Align WritableStream structure with ReadableStream structure #488
Conversation
tyoshino
commented
Aug 1, 2016
•
edited
Loading
edited
- Add WritableStreamDefaultWriter
- Add WritableStreamDefaultController
- Add lock related methods
- Update reader.pipeTo() to use the new WritableStream classes
- Refine reader.pipeTo()'s error handling
- Update TransformStream to use the new WritableStream classes
- Refine TransformStream's error handling
- Document the difference between ReadableStream's locking (releaseLock()) and WritableStream's one
- WritableStream's reader's releaseLock() doesn't check pending writes
- moved to Document difference of lock between writable and readable #516
- Add WritableStreamDefaultWriter - Add WritableStreamDefaultController - Add lock related methods - Update reader.pipeTo() to use the new WritableStream classes
Squashed and rebased version of #462. |
I inserted a lot of logs this time for debugging pipeTo(). I'd like to leave some or all of them in the reference impl for debugging in the future. Do you have any opinion about that, Domenic? |
In rewriting pipeTo() algorithm, I felt that it's good if we apply some convention to variable naming to distinguish variables local to the inner functions and ones of pipeTo() like how we're distinguishing internal slots and local variables. I'm tentatively prefixing them with _. |
I think we should at least comment them out when committing to the repo. In the future we could investigate a logging framework that allows us to toggle them on and off with environment variables, like https://www.npmjs.com/package/debug maybe. |
|
||
this._readyPromise = Promise.resolve(undefined); | ||
this._readyPromise_resolve = null; | ||
this._writeRequests = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment that these are kept here instead of on the writer because we want to allow multiple queued up writes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by e57e25e
I'm not sure if it's what you meant. Please take a look again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that is exactly what I meant, sorry, I was pretty unclear.
} | ||
|
||
if (IsWritableStreamLocked(this) === true) { | ||
return Promise.reject(new TypeError('Cannot abort a stream that already has a reader')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/reader/writer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by e57e25e
Addresses comment #488 (comment)
|
||
return undefined; | ||
WritableStreamFulfillWriteRequest(stream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not fulfill the write request normally? Why is the last write request special?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_writeRequests now holds both pending write and pending close. That's why we're calling this here.
Review finished :). Seems like you've got most of my comments already. Big ones are |
See the context at: #488 (comment)
In general we are loathe to introduce this kind of departure from the spec. However, it improves our ability to run the tests quickly by a very large factor. See the context at #488 (comment).
I think this is ready! What about you? |
Draft commit message: Add locking and precise flow control to WritableStream This fixes #319 (by adding locking and the concept of a writable stream writer) and fixes #318 (by adding precise flow control via the writer.desiredSize property). The structure parallels that introduced for ReadableStream, including the introduction of a controller class. The infrastructure is set up to allow the future introduction of different types of writable streams (with corresponding new controllers and writers). With this in place, the public API for writable streams is almost stable; the remaining issue is whether writers should have a ready promise, or a waitForDesiredSize() method which could in the future be customized by passing an argument (see discussions in #318). The reference implementation's pipeTo and transform stream code has been updated, and all the tests pass, but they haven't been put in the spec yet, as their design is not yet finalized (but is much closer to now that they have a more stable WritableStream foundation). Merge at will! |
Merged as 5a27534 |
Done by 28c20b1 |