| 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; | |
| 6 | |
| 7 import 'dart:async'; | 5 import 'dart:async'; |
| 8 | 6 |
| 9 import '../result.dart'; | |
| 10 import 'future_group.dart'; | 7 import 'future_group.dart'; |
| 8 import 'result.dart'; |
| 11 | 9 |
| 12 /// A class that splits a single source stream into an arbitrary number of | 10 /// A class that splits a single source stream into an arbitrary number of |
| 13 /// (single-subscription) streams (called "branch") that emit the same events. | 11 /// (single-subscription) streams (called "branch") that emit the same events. |
| 14 /// | 12 /// |
| 15 /// Each branch will emit all the same values and errors as the source stream, | 13 /// Each branch will emit all the same values and errors as the source stream, |
| 16 /// regardless of which values have been emitted on other branches. This means | 14 /// regardless of which values have been emitted on other branches. This means |
| 17 /// that the splitter stores every event that has been emitted so far, which may | 15 /// that the splitter stores every event that has been emitted so far, which may |
| 18 /// consume a lot of memory. The user can call [close] to indicate that no more | 16 /// consume a lot of memory. The user can call [close] to indicate that no more |
| 19 /// branches will be created, and this memory will be released. | 17 /// branches will be created, and this memory will be released. |
| 20 /// | 18 /// |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 201 } |
| 204 | 202 |
| 205 /// Marks [_controllers] as done. | 203 /// Marks [_controllers] as done. |
| 206 void _onDone() { | 204 void _onDone() { |
| 207 _isDone = true; | 205 _isDone = true; |
| 208 for (var controller in _controllers) { | 206 for (var controller in _controllers) { |
| 209 _closeGroup.add(controller.close()); | 207 _closeGroup.add(controller.close()); |
| 210 } | 208 } |
| 211 } | 209 } |
| 212 } | 210 } |
| OLD | NEW |