| OLD | NEW |
| 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 barback.group_runner; | 5 library barback.group_runner; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'asset_cascade.dart'; | 9 import 'asset_cascade.dart'; |
| 10 import 'asset_node.dart'; | 10 import 'asset_node.dart'; |
| 11 import 'log.dart'; | 11 import 'log.dart'; |
| 12 import 'phase.dart'; | 12 import 'phase.dart'; |
| 13 import 'stream_pool.dart'; | 13 import 'stream_pool.dart'; |
| 14 import 'transformer_group.dart'; | 14 import 'transformer_group.dart'; |
| 15 | 15 |
| 16 /// A class that processes all of the phases in a single transformer group. | 16 /// A class that processes all of the phases in a single transformer group. |
| 17 /// | 17 /// |
| 18 /// A group takes many inputs, processes them, and emits many outputs. | 18 /// A group takes many inputs, processes them, and emits many outputs. |
| 19 class GroupRunner { | 19 class GroupRunner { |
| 20 /// The group this runner runs. | 20 /// The group this runner runs. |
| 21 final TransformerGroup _group; | 21 final TransformerGroup _group; |
| 22 | 22 |
| 23 /// A string describing the location of [this] in the transformer graph. | 23 /// A string describing the location of [this] in the transformer graph. |
| 24 final String _location; | 24 final String _location; |
| 25 | 25 |
| 26 /// The phases defined by this group. | 26 /// The phases defined by this group. |
| 27 final _phases = new List<Phase>(); | 27 final _phases = new List<Phase>(); |
| 28 | 28 |
| 29 /// Whether [this] is dirty and still has more processing to do. | 29 /// Whether [this] is dirty and still has more processing to do. |
| 30 bool get isDirty => _phases.any((phase) => phase.isDirty); | 30 bool get isDirty { |
| 31 // Just check the last phase, since it will check all the previous phases |
| 32 // itself. |
| 33 return _phases.last.isDirty; |
| 34 } |
| 31 | 35 |
| 32 /// A stream that emits an event whenever [this] is no longer dirty. | 36 /// A stream that emits an event whenever [this] is no longer dirty. |
| 33 /// | 37 /// |
| 34 /// This is synchronous in order to guarantee that it will emit an event as | 38 /// This is synchronous in order to guarantee that it will emit an event as |
| 35 /// soon as [isDirty] flips from `true` to `false`. | 39 /// soon as [isDirty] flips from `true` to `false`. |
| 36 Stream get onDone => _onDoneController.stream; | 40 Stream get onDone => _onDoneController.stream; |
| 37 final _onDoneController = new StreamController.broadcast(sync: true); | 41 final _onDoneController = new StreamController.broadcast(sync: true); |
| 38 | 42 |
| 39 /// A stream that emits any new assets emitted by [this]. | 43 /// A stream that emits any new assets emitted by [this]. |
| 40 /// | 44 /// |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 _phases.first.addInput(node); | 86 _phases.first.addInput(node); |
| 83 } | 87 } |
| 84 | 88 |
| 85 /// Removes this group and all sub-phases within it. | 89 /// Removes this group and all sub-phases within it. |
| 86 void remove() { | 90 void remove() { |
| 87 _phases.first.remove(); | 91 _phases.first.remove(); |
| 88 } | 92 } |
| 89 | 93 |
| 90 String toString() => "group in phase $_location for $_group"; | 94 String toString() => "group in phase $_location for $_group"; |
| 91 } | 95 } |
| OLD | NEW |