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

Side by Side Diff: lib/src/util/multi_channel.dart

Issue 1083543004: Only consider a multichannel closed when the underlying channel closes. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | no next file » | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 test.multi_channel; 5 library test.multi_channel;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'stream_channel.dart'; 9 import 'stream_channel.dart';
10 10
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 onDone: () => _closeChannel(inputId, outputId)); 195 onDone: () => _closeChannel(inputId, outputId));
196 196
197 return new VirtualChannel._( 197 return new VirtualChannel._(
198 this, outputId, streamController.stream, sinkController.sink); 198 this, outputId, streamController.stream, sinkController.sink);
199 } 199 }
200 200
201 /// Closes the virtual channel for which incoming messages have [inputId] and 201 /// Closes the virtual channel for which incoming messages have [inputId] and
202 /// outgoing messages have [outputId]. 202 /// outgoing messages have [outputId].
203 void _closeChannel(int inputId, int outputId) { 203 void _closeChannel(int inputId, int outputId) {
204 if (_closed) return; 204 if (_closed) return;
205 _closed = true; 205 _closed = inputId == 0;
206 206
207 // A message without data indicates that the virtual channel has been 207 // A message without data indicates that the virtual channel has been
208 // closed. 208 // closed.
209 _streamControllers.remove(inputId).close(); 209 _streamControllers.remove(inputId).close();
210 _sinkControllers.remove(inputId).close(); 210 _sinkControllers.remove(inputId).close();
211 211
212 if (_innerSink == null) return; 212 if (_innerSink == null) return;
213 _innerSink.add([outputId]); 213 _innerSink.add([outputId]);
214 if (_streamControllers.isEmpty) _closeInnerChannel(); 214 if (_streamControllers.isEmpty) _closeInnerChannel();
215 } 215 }
(...skipping 26 matching lines...) Expand all
242 /// except that it will be JSON-serializable. 242 /// except that it will be JSON-serializable.
243 final id; 243 final id;
244 244
245 final Stream stream; 245 final Stream stream;
246 final StreamSink sink; 246 final StreamSink sink;
247 247
248 VirtualChannel._(this._parent, this.id, this.stream, this.sink); 248 VirtualChannel._(this._parent, this.id, this.stream, this.sink);
249 249
250 VirtualChannel virtualChannel([id]) => _parent.virtualChannel(id); 250 VirtualChannel virtualChannel([id]) => _parent.virtualChannel(id);
251 } 251 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698