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

Issue 16240008: Make StreamController be a StreamSink, not just an EventSink. (Closed)

Created:
7 years, 6 months ago by Lasse Reichstein Nielsen
Modified:
7 years, 5 months ago
Reviewers:
floitsch
CC:
reviews_dartlang.org, zarah
Visibility:
Public.

Description

Make StreamController be a StreamSink, not just an EventSink. BUG=http://dartbug.com/10677 R=floitsch@google.com Committed: https://code.google.com/p/dart/source/detail?r=24587

Patch Set 1 #

Total comments: 6

Patch Set 2 : Complete rewrite. StreamController is now itself a StreamSink. #

Total comments: 39

Patch Set 3 : Address review comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1014 lines, -466 lines) Patch
M sdk/lib/async/async.dart View 1 1 chunk +1 line, -0 lines 0 comments Download
M sdk/lib/async/async_sources.gypi View 1 1 chunk +1 line, -0 lines 0 comments Download
A sdk/lib/async/broadcast_stream_controller.dart View 1 2 1 chunk +492 lines, -0 lines 0 comments Download
M sdk/lib/async/future_impl.dart View 1 2 7 chunks +35 lines, -12 lines 0 comments Download
M sdk/lib/async/stream.dart View 1 1 chunk +0 lines, -13 lines 0 comments Download
M sdk/lib/async/stream_controller.dart View 1 2 11 chunks +356 lines, -436 lines 0 comments Download
M sdk/lib/async/stream_impl.dart View 1 1 chunk +5 lines, -2 lines 0 comments Download
M tests/lib/async/event_helper.dart View 1 3 chunks +8 lines, -0 lines 0 comments Download
M tests/lib/async/stream_controller_async_test.dart View 1 2 3 chunks +114 lines, -1 line 0 comments Download
M tests/lib/async/stream_controller_test.dart View 2 chunks +2 lines, -2 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
Lasse Reichstein Nielsen
7 years, 6 months ago (2013-05-31 13:07:46 UTC) #1
floitsch
LGTM once test is addressed. Also: should we make a StreamController implement StreamSink? https://codereview.chromium.org/16240008/diff/1/sdk/lib/async/stream_controller.dart File ...
7 years, 6 months ago (2013-06-06 15:08:29 UTC) #2
Lasse Reichstein Nielsen
I think it would make great sense to make the constroller itself a StreamSink. Let's ...
7 years, 6 months ago (2013-06-10 13:52:56 UTC) #3
Lasse Reichstein Nielsen
Complete rewrite, PTAL.
7 years, 5 months ago (2013-06-27 07:46:52 UTC) #4
floitsch
LGTM, but I think that an addStream on a stream-controller should never complete with an ...
7 years, 5 months ago (2013-06-27 15:15:18 UTC) #5
floitsch
Also: please run the dart-analyzer (or open in the editor), if you haven't done so.
7 years, 5 months ago (2013-06-27 16:27:00 UTC) #6
Lasse Reichstein Nielsen
Committed patchset #3 manually as r24587 (presubmit successful).
7 years, 5 months ago (2013-06-28 12:56:45 UTC) #7
Lasse Reichstein Nielsen
7 years, 5 months ago (2013-06-28 12:57:38 UTC) #8
Message was sent while issue was closed.
https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/broadcast_st...
File sdk/lib/async/broadcast_stream_controller.dart (right):

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/broadcast_st...
sdk/lib/async/broadcast_stream_controller.dart:51: bool _expectsEvent(int
eventId) {
Will do. 
Probably added the block to be able to do more during debugging.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/broadcast_st...
sdk/lib/async/broadcast_stream_controller.dart:55: void _toggleEventId() {
doesn't return a value.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/broadcast_st...
sdk/lib/async/broadcast_stream_controller.dart:66: bool get _removeAfterFiring
=>
This is an imperative. It must be removed after firing. And it WILL be removed
after firing. There is no "should" about it.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/broadcast_st...
sdk/lib/async/broadcast_stream_controller.dart:72: }
It's inherited. We overwrite _onPause and _onResume because we know they will do
nothing, so there is no need to call the controller's _recordPause/Resume to do
nothing there.

Added comments.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/broadcast_st...
sdk/lib/async/broadcast_stream_controller.dart:105: * This means when all
listeners at the time when the done event was
Reworded.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/broadcast_st...
sdk/lib/async/broadcast_stream_controller.dart:159: previous._next =
subscription;
On 2013/06/27 15:15:19, floitsch wrote:
> needs comments.
> Either explain that you want to accept cyclic lists, or don't do magic things
> with subscription._previous.

Done.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/broadcast_st...
sdk/lib/async/broadcast_stream_controller.dart:169: subscription._previous._next
= subscription._next;
On 2013/06/27 15:15:19, floitsch wrote:
> please make this nicer to read:
> var prev = sub.prev;
> var next = sub.next;
> prev.next = next;
> next.prev = prev;
> sub.next = sub.prev = sub;

Done.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/broadcast_st...
sdk/lib/async/broadcast_stream_controller.dart:183: return new
_DoneSubscription<T>();
On 2013/06/27 15:15:19, floitsch wrote:
> Let's throw instead.

Done.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/broadcast_st...
sdk/lib/async/broadcast_stream_controller.dart:206: if ((_state & _STATE_FIRING)
== 0 && _isEmpty) {
On 2013/06/27 15:15:19, floitsch wrote:
> if (!_isFiring && _isEmpty)

Done.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/broadcast_st...
sdk/lib/async/broadcast_stream_controller.dart:257: // _EventSink interface,
called from AddStramState.
On 2013/06/27 15:15:19, floitsch wrote:
> AddStreamState

Done.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/broadcast_st...
sdk/lib/async/broadcast_stream_controller.dart:263: assert(_isAddingStream);
Let's pass it through, the controller can handle it.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/future_impl....
File sdk/lib/async/future_impl.dart (right):

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/future_impl....
sdk/lib/async/future_impl.dart:318: void _setErrorUnchecked(error) {
On 2013/06/27 15:15:19, floitsch wrote:
> If you add the "Object" above, also add it here.

Done.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/stream_contr...
File sdk/lib/async/stream_controller.dart (right):

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/stream_contr...
sdk/lib/async/stream_controller.dart:140: * If true, the "done" event might not
have _ yet, but it has been
On 2013/06/27 15:15:19, floitsch wrote:
> undo change?

Done.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/stream_contr...
sdk/lib/async/stream_controller.dart:211: // If executing an [addStream], now
events are not allowed either, but will
now -> new.
Reworded and reordered.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/stream_contr...
sdk/lib/async/stream_controller.dart:421: // Error from addStream. Stop the
addStream and complete its future with the
On 2013/06/27 15:15:19, floitsch wrote:
> I don't think that's the right thing to do. Just pass it through.

Done.

https://codereview.chromium.org/16240008/diff/7001/sdk/lib/async/stream_contr...
sdk/lib/async/stream_controller.dart:632: StreamSink _target;
On 2013/06/27 15:15:19, floitsch wrote:
> final.

Done.

https://codereview.chromium.org/16240008/diff/7001/tests/lib/async/stream_con...
File tests/lib/async/stream_controller_async_test.dart (right):

https://codereview.chromium.org/16240008/diff/7001/tests/lib/async/stream_con...
tests/lib/async/stream_controller_async_test.dart:548: // stream, it will still
be open, and we read the done" future before
On 2013/06/27 15:15:19, floitsch wrote:
> spurious '"'.

Done.

https://codereview.chromium.org/16240008/diff/7001/tests/lib/async/stream_con...
tests/lib/async/stream_controller_async_test.dart:581: () => null));
On 2013/06/27 15:15:19, floitsch wrote:
> bad indentation

Done.

https://codereview.chromium.org/16240008/diff/7001/tests/lib/async/stream_con...
tests/lib/async/stream_controller_async_test.dart:595: .then((_) {
I'll try adding a pause here (50 ms, just to be sure we're past the 15ms pause).

Powered by Google App Engine
This is Rietveld 408576698