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

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

Issue 48733002: Fix bugs in StreamController.addStream. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Added test. Fixed typos. Created 7 years, 1 month 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 | « no previous file | sdk/lib/async/stream_controller.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 class _BroadcastStream<T> extends _ControllerStream<T> { 7 class _BroadcastStream<T> extends _ControllerStream<T> {
8 _BroadcastStream(_StreamControllerLifecycle controller) : super(controller); 8 _BroadcastStream(_StreamControllerLifecycle controller) : super(controller);
9 9
10 bool get isBroadcast => true; 10 bool get isBroadcast => true;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 } 231 }
232 if (!_mayAddEvent) throw _addEventError(); 232 if (!_mayAddEvent) throw _addEventError();
233 _state |= _STATE_CLOSED; 233 _state |= _STATE_CLOSED;
234 Future doneFuture = _ensureDoneFuture(); 234 Future doneFuture = _ensureDoneFuture();
235 _sendDone(); 235 _sendDone();
236 return doneFuture; 236 return doneFuture;
237 } 237 }
238 238
239 Future get done => _ensureDoneFuture(); 239 Future get done => _ensureDoneFuture();
240 240
241 Future addStream(Stream<T> stream) { 241 Future addStream(Stream<T> stream, {bool cancelOnError: true}) {
242 if (!_mayAddEvent) throw _addEventError(); 242 if (!_mayAddEvent) throw _addEventError();
243 _state |= _STATE_ADDSTREAM; 243 _state |= _STATE_ADDSTREAM;
244 _addStreamState = new _AddStreamState(this, stream); 244 _addStreamState = new _AddStreamState(this, stream, cancelOnError);
245 return _addStreamState.addStreamFuture; 245 return _addStreamState.addStreamFuture;
246 } 246 }
247 247
248 // _EventSink interface, called from AddStreamState. 248 // _EventSink interface, called from AddStreamState.
249 void _add(T data) { 249 void _add(T data) {
250 _sendData(data); 250 _sendData(data);
251 } 251 }
252 252
253 void _addError(Object error, StackTrace stackTrace) { 253 void _addError(Object error, StackTrace stackTrace) {
254 assert(_isAddingStream); 254 assert(_isAddingStream);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 _pauseCount++; 469 _pauseCount++;
470 } 470 }
471 void resume() { _resume(null); } 471 void resume() { _resume(null); }
472 void _resume(_) { 472 void _resume(_) {
473 if (_pauseCount > 0) _pauseCount--; 473 if (_pauseCount > 0) _pauseCount--;
474 } 474 }
475 void cancel() {} 475 void cancel() {}
476 bool get isPaused => _pauseCount > 0; 476 bool get isPaused => _pauseCount > 0;
477 Future asFuture([Object value]) => new _Future(); 477 Future asFuture([Object value]) => new _Future();
478 } 478 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/async/stream_controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698