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

Side by Side Diff: lib/src/isolate_channel.dart

Issue 1632903004: Add StreamChannelTransformer. (Closed) Base URL: git@github.com:dart-lang/stream_channel.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:isolate'; 6 import 'dart:isolate';
7 7
8 import '../stream_channel.dart'; 8 import '../stream_channel.dart';
9 9
10 /// A [StreamChannel] that communicates over a [ReceivePort]/[SendPort] pair, 10 /// A [StreamChannel] that communicates over a [ReceivePort]/[SendPort] pair,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 122
123 return done; 123 return done;
124 } 124 }
125 125
126 Future addStream(Stream<T> stream) { 126 Future addStream(Stream<T> stream) {
127 if (_closed) throw new StateError("Cannot add stream after closing."); 127 if (_closed) throw new StateError("Cannot add stream after closing.");
128 if (_inAddStream) { 128 if (_inAddStream) {
129 throw new StateError("Cannot add stream while adding stream."); 129 throw new StateError("Cannot add stream while adding stream.");
130 } 130 }
131 if (_isDone) return; 131 if (_isDone) return new Future.value();
Bob Nystrom 2016/01/27 19:30:40 I wonder if it would be cleaner to make the functi
nweiz 2016/01/27 23:23:49 It seems weird to have the errors thrown asynchron
132 132
133 _inAddStream = true; 133 _inAddStream = true;
134 var completer = new Completer.sync(); 134 var completer = new Completer.sync();
135 stream.listen(_add, 135 stream.listen(_add,
136 onError: (error, stackTrace) { 136 onError: (error, stackTrace) {
137 _close(error, stackTrace); 137 _close(error, stackTrace);
138 completer.complete(); 138 completer.complete();
139 }, 139 },
140 onDone: completer.complete, 140 onDone: completer.complete,
141 cancelOnError: true); 141 cancelOnError: true);
142 return completer.future.then((_) { 142 return completer.future.then((_) {
143 _inAddStream = false; 143 _inAddStream = false;
144 }); 144 });
145 } 145 }
146 } 146 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/stream_channel_transformer.dart » ('j') | lib/src/stream_channel_transformer.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698