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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/error_group.dart

Issue 16125005: Make new StreamController be async by default. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 7 years, 6 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library error_group; 5 library error_group;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'utils.dart'; 9 import 'utils.dart';
10 10
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 /// The [StreamSubscription] that connects the wrapped [Stream] to 232 /// The [StreamSubscription] that connects the wrapped [Stream] to
233 /// [_controller]. 233 /// [_controller].
234 StreamSubscription _subscription; 234 StreamSubscription _subscription;
235 235
236 /// Whether [this] has any listeners. 236 /// Whether [this] has any listeners.
237 bool get _hasListeners => _controller.hasListener; 237 bool get _hasListeners => _controller.hasListener;
238 238
239 /// Creates a new [_ErrorGroupFuture] that's a child of [_group] and wraps 239 /// Creates a new [_ErrorGroupFuture] that's a child of [_group] and wraps
240 /// [inner]. 240 /// [inner].
241 _ErrorGroupStream(this._group, Stream inner) 241 _ErrorGroupStream(this._group, Stream inner)
242 : _controller = new StreamController() { 242 : _controller = new StreamController(sync: true) {
243 this._stream = inner.isBroadcast 243 this._stream = inner.isBroadcast
244 ? _controller.stream.asBroadcastStream() 244 ? _controller.stream.asBroadcastStream()
245 : _controller.stream; 245 : _controller.stream;
246 _subscription = inner.listen((v) { 246 _subscription = inner.listen((v) {
247 _controller.add(v); 247 _controller.add(v);
248 }, onError: (e) { 248 }, onError: (e) {
249 _group._signalError(e); 249 _group._signalError(e);
250 }, onDone: () { 250 }, onDone: () {
251 _isDone = true; 251 _isDone = true;
252 _group._signalStreamComplete(this); 252 _group._signalStreamComplete(this);
(...skipping 15 matching lines...) Expand all
268 void _signalError(var e) { 268 void _signalError(var e) {
269 if (_isDone) return; 269 if (_isDone) return;
270 _subscription.cancel(); 270 _subscription.cancel();
271 // Call these asynchronously to work around issue 7913. 271 // Call these asynchronously to work around issue 7913.
272 new Future.value().then((_) { 272 new Future.value().then((_) {
273 _controller.addError(e); 273 _controller.addError(e);
274 _controller.close(); 274 _controller.close();
275 }); 275 });
276 } 276 }
277 } 277 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart2js.dart ('k') | sdk/lib/_internal/pub/lib/src/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698