OLD | NEW |
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 async.stream_splitter; | 5 library async.stream_splitter; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import '../result.dart'; | 10 import '../result.dart'; |
(...skipping 17 matching lines...) Expand all Loading... |
28 /// The wrapped stream. | 28 /// The wrapped stream. |
29 final Stream<T> _stream; | 29 final Stream<T> _stream; |
30 | 30 |
31 /// The subscription to [_stream]. | 31 /// The subscription to [_stream]. |
32 /// | 32 /// |
33 /// This will be `null` until a branch has a listener. | 33 /// This will be `null` until a branch has a listener. |
34 StreamSubscription<T> _subscription; | 34 StreamSubscription<T> _subscription; |
35 | 35 |
36 /// The buffer of events or errors that have already been emitted by | 36 /// The buffer of events or errors that have already been emitted by |
37 /// [_stream]. | 37 /// [_stream]. |
38 final _buffer = new Queue<Result<T>>(); | 38 final _buffer = new List<Result<T>>(); |
39 | 39 |
40 /// The controllers for branches that are listening for future events from | 40 /// The controllers for branches that are listening for future events from |
41 /// [_stream]. | 41 /// [_stream]. |
42 /// | 42 /// |
43 /// Once a branch is canceled, it's removed from this list. When [_stream] is | 43 /// Once a branch is canceled, it's removed from this list. When [_stream] is |
44 /// done, all branches are removed. | 44 /// done, all branches are removed. |
45 final _controllers = new Set<StreamController<T>>(); | 45 final _controllers = new Set<StreamController<T>>(); |
46 | 46 |
47 /// A group of futures returned by [close]. | 47 /// A group of futures returned by [close]. |
48 /// | 48 /// |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 204 } |
205 | 205 |
206 /// Marks [_controllers] as done. | 206 /// Marks [_controllers] as done. |
207 void _onDone() { | 207 void _onDone() { |
208 _isDone = true; | 208 _isDone = true; |
209 for (var controller in _controllers) { | 209 for (var controller in _controllers) { |
210 _closeGroup.add(controller.close()); | 210 _closeGroup.add(controller.close()); |
211 } | 211 } |
212 } | 212 } |
213 } | 213 } |
OLD | NEW |