Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Issue 1241723003: Add StreamQueue.fork and ForkableStream. (Closed)

Created:
5 years, 5 months ago by nweiz
Modified:
5 years, 4 months ago
CC:
reviews_dartlang.org
Base URL:
git@github.com:dart-lang/async.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Add StreamQueue.fork and ForkableStream. StramQueue.fork is a very useful operation for creating complex and composable user-defined operations over stream queues. It allows arbitrary lookahead to be performed without modifying the semantics of the original stream, providing for higher-order operations like "check for this sequence of values or, if they don't exist, this other distinct sequence". Committed: https://github.com/dart-lang/async/commit/312d39641225b64b275e57d167b57a87b335654a

Patch Set 1 #

Total comments: 24
Unified diffs Side-by-side diffs Delta from patch set Stats (+1098 lines, -5 lines) Patch
M CHANGELOG.md View 1 chunk +3 lines, -0 lines 0 comments Download
M lib/async.dart View 1 chunk +1 line, -0 lines 0 comments Download
A lib/src/forkable_stream.dart View 1 chunk +163 lines, -0 lines 18 comments Download
M lib/src/stream_queue.dart View 7 chunks +72 lines, -4 lines 6 comments Download
A test/forkable_stream_test.dart View 1 chunk +413 lines, -0 lines 0 comments Download
M test/stream_queue_test.dart View 4 chunks +446 lines, -1 line 0 comments Download

Messages

Total messages: 11 (1 generated)
nweiz
5 years, 5 months ago (2015-07-14 20:19:17 UTC) #2
Lasse Reichstein Nielsen
https://codereview.chromium.org/1241723003/diff/1/lib/src/forkable_stream.dart File lib/src/forkable_stream.dart (right): https://codereview.chromium.org/1241723003/diff/1/lib/src/forkable_stream.dart#newcode23 lib/src/forkable_stream.dart:23: /// then canceled. It seems it will be cancelled ...
5 years, 5 months ago (2015-07-15 20:07:12 UTC) #3
Lasse Reichstein Nielsen
https://codereview.chromium.org/1241723003/diff/1/lib/src/stream_queue.dart File lib/src/stream_queue.dart (right): https://codereview.chromium.org/1241723003/diff/1/lib/src/stream_queue.dart#newcode110 lib/src/stream_queue.dart:110: : new ForkableStream(source); Would it be possible to make ...
5 years, 5 months ago (2015-07-15 20:10:51 UTC) #4
nweiz
Committed patchset #1 (id:1) manually as 312d39641225b64b275e57d167b57a87b335654a (presubmit successful).
5 years, 5 months ago (2015-07-15 22:18:40 UTC) #5
nweiz
I accidentally landed this CL instead of uploading it for further review. Oops! I'll make ...
5 years, 5 months ago (2015-07-15 22:19:43 UTC) #6
Lasse Reichstein Nielsen
https://codereview.chromium.org/1241723003/diff/1/lib/src/forkable_stream.dart File lib/src/forkable_stream.dart (right): https://codereview.chromium.org/1241723003/diff/1/lib/src/forkable_stream.dart#newcode62 lib/src/forkable_stream.dart:62: Stream<T> fork() => _fork(primary: false); I don't think fork ...
5 years, 5 months ago (2015-07-16 14:01:23 UTC) #7
Lasse Reichstein Nielsen
So, in general, I'm not convinced. Maybe revert it for now, and we can look ...
5 years, 5 months ago (2015-07-17 18:43:29 UTC) #8
nweiz
I've reverted the change, but I do think this is very important for the reasons ...
5 years, 5 months ago (2015-07-17 20:30:16 UTC) #9
Lasse Reichstein Nielsen
On 2015/07/17 20:30:16, nweiz wrote: > I've reverted the change, but I do think this ...
5 years, 4 months ago (2015-08-03 11:43:18 UTC) #10
Lasse Reichstein Nielsen
5 years, 4 months ago (2015-08-17 11:14:00 UTC) #11
Message was sent while issue was closed.
I've been trying to see if I can find a way to make a forkable stream queue
without overhead for, and without complicating, the non-forked use case. So far
it hasn't worked out very well.

I will maintain that forking a stream is not something that belongs on the
stream. 

There is nothing wrong with taking a stream and explicitly creating more streams
from its events, but having it implicit in the stream (by having a "fork" on the
stream) is hiding the complexity. The Stream has one job - deliver events.
Putting extra functionality onto the stream is muddying that and creating a new
type of stream that nobody else knows about anyway. Same for StreamQueue - it's
intended as a better StreamIterator, and it provides the events of a single
stream.

I believe that forking is useful when testing, but I don't see a way of making
it a simple and efficient basic operation, so perhaps we should instead make
something specialized for testing instead of trying to fit testing functionality
into existing classes.

All in all, I don't think forkable stream or stream-queue is a good enough idea
and/or choice of design that it is worth the complexity that it introduces.

Powered by Google App Engine
This is Rietveld 408576698