- From: Domenic Denicola <notifications@github.com>
- Date: Thu, 09 Apr 2015 17:40:09 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Message-ID: <whatwg/streams/issues/325/91389926@github.com>
This is really good analysis but I'm not 100% sure I understand it all, so please be patient with me :). First, some quick comments on points that caught my eye: > Without an ability to stop rs.pipeTo(id.writable), we never be able to switch to rs.specialDataTransfer(ws). We've wanted a way to cancel a pipe since at least https://github.com/whatwg/streams/commit/726b08d4696758b28c566f84f2eec7b10d5e1bdf. Our solution is cancelable promises, but even before they land we could have a spec mechanism like CancelCurrentPipe(rs) that will eventually be exposed through `pipePromise.cancel()` but until then will be usable by UA-created streams or other internal algorithms. So maybe this helps. > Provide an (possibly private) API, say .redirectTo, on the WritableStream for .pipeTo() algorithm to redirect .specialDataTransfer() to ws. ReadableStream.pipeTo() is required to check .redirectTo before every dest.write() and if it's set, it must switch to use rs.specialDataTransfer(dest.redirectTo). This is kind of interesting and I think could eventually be massaged into something more elegant. It reminds me a bit of #146. But I agree it is complex and a simpler version would be nice. --- Second a question to see if I understand the problematic scenario: ```js id.writable.write("hello"); id.writable.write("world"); rs.pipeTo(id.writable); id.readable.pipeTo(ws); ``` Our goal here in an ideal world for the outcome would be: - "hello" makes its way to `ws` (not respecting backpressure) - "world" makes its way to `ws` (not respecting backpressure) - Once `ws` stops giving off backpressure signals (including any triggered by "hello" or "world"), we run `rs.specialDataTransfer(ws)`. Is that right? Did I miss anything? If so, this doesn't seem too hard to solve. I'm not sure how we would specify the exact protocol (including the issues of #307, of how to identify that a stream is identity and can be skipped---maybe that is your redirectTo idea!? I think it is now that I re-read.) But I think an algorithm of "wait for ultimate-non-identity-ready, then do special data transfer" is doable. I guess the heart of this concern is coming up with a protocol such that, in the special case where once there is nothing buffered in the identity transform and both the `writable` side has something piped to it and the `readable` side is piped somewhere, we can do `rs.pipeTo(ws)` (assuming `rs.pipeTo` has special-data-transfer logic). Given that with #321 `pipeTo`'s internals are effectively unobservable, we should have a lot of latitude in designing this protocol, I hope. An alternate approach is to say that identity transforms are special and don't use the normal `readable` and `writable` but instead use something more like operation stream while exposing the same public interface as readable and writable... That's a bit tricky though. It would be good to prototype this kind of thing as it has the flavor of something that needs actual testing to see if the edge cases work. --- Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/issues/325#issuecomment-91389926
Received on Friday, 10 April 2015 00:40:37 UTC