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

Side by Side Diff: sdk/lib/async/stream_impl.dart

Issue 18080015: Revert "Make StreamController be a StreamSink, not just an EventSink." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/async/stream_controller.dart ('k') | tests/lib/async/event_helper.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.async; 5 part of dart.async;
6 6
7 /** Abstract and private interface for a place to put events. */ 7 /** Abstract and private interface for a place to put events. */
8 abstract class _EventSink<T> { 8 abstract class _EventSink<T> {
9 void _add(T data); 9 void _add(T data);
10 void _addError(Object error); 10 void _addError(Object error);
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 void onDone(), 712 void onDone(),
713 bool cancelOnError}) { 713 bool cancelOnError}) {
714 if (_controller == null) { 714 if (_controller == null) {
715 throw new StateError("Source stream has been closed."); 715 throw new StateError("Source stream has been closed.");
716 } 716 }
717 if (_subscription == null) { 717 if (_subscription == null) {
718 _subscription = _source.listen(_controller.add, 718 _subscription = _source.listen(_controller.add,
719 onError: _controller.addError, 719 onError: _controller.addError,
720 onDone: _controller.close); 720 onDone: _controller.close);
721 } 721 }
722 if (onData == null) onData = _nullDataHandler; 722 return _controller.stream.listen(onData, onError: onError, onDone: onDone,
723 if (onError == null) onError = _nullErrorHandler; 723 cancelOnError: cancelOnError);
724 if (onDone == null) onDone = _nullDoneHandler;
725 cancelOnError = identical(true, cancelOnError);
726 return _controller._subscribe(onData, onError, onDone, cancelOnError);
727 } 724 }
728 725
729 void _onCancel() { 726 void _onCancel() {
730 // Called by [_controller] when it has no subscribers left. 727 // Called by [_controller] when it has no subscribers left.
731 StreamSubscription subscription = _subscription; 728 StreamSubscription subscription = _subscription;
732 _subscription = null; 729 _subscription = null;
733 _controller = null; // Marks the stream as no longer listenable. 730 _controller = null; // Marks the stream as no longer listenable.
734 subscription.cancel(); 731 subscription.cancel();
735 } 732 }
736 } 733 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 _FutureImpl<bool> hasNext = _futureOrPrefetch; 875 _FutureImpl<bool> hasNext = _futureOrPrefetch;
879 _clear(); 876 _clear();
880 hasNext._setValue(false); 877 hasNext._setValue(false);
881 return; 878 return;
882 } 879 }
883 _subscription.pause(); 880 _subscription.pause();
884 _futureOrPrefetch = null; 881 _futureOrPrefetch = null;
885 _state = _STATE_EXTRA_DONE; 882 _state = _STATE_EXTRA_DONE;
886 } 883 }
887 } 884 }
OLDNEW
« no previous file with comments | « sdk/lib/async/stream_controller.dart ('k') | tests/lib/async/event_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698