- From: Takeshi Yoshino <notifications@github.com>
- Date: Wed, 01 Jun 2016 00:04:44 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc:
- Message-ID: <whatwg/streams/issues/465@github.com>
A WritableStream invokes its underlying sink's `write()` method for each chunk in its queue. This completes only asynchronously on invocation of the fulfillment callback set to the promise returned by the `write()` call. This means that one microtask is required to process each chunk. We could change this to allow for synchronous draining by introducing an interface similar to the `byobRequest` interface we've adopted for responding to BYOB reading in the underlying source of ReadableStream. It'll be like: - when a new chunk is enqueued, `write()` (or could be renamed to `push()`) is invoked to notify the sink of that there're some chunks available for processing (redundant invocation is still prevented by the `_writing` flag). - WritableStreamDefaultController has a getter named `writeRequest()` which has `get chunk()` and `ack()` method. - Calling `ack()` tells the WritableStream to fulfill the promise returned on `write()` call on the WritableStream. - Once `ack()` is called, `writeRequest()` is updated to represent the next chunk in the queue. If there's no chunk, it returns **undefined**. --- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/issues/465
Received on Wednesday, 1 June 2016 07:05:15 UTC