Chromium Code Reviews| 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.phase; | 5 library barback.phase; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'asset_cascade.dart'; | 10 import 'asset_cascade.dart'; |
| 11 import 'asset_id.dart'; | 11 import 'asset_id.dart'; |
| 12 import 'asset_node.dart'; | 12 import 'asset_node.dart'; |
| 13 import 'asset_set.dart'; | 13 import 'asset_set.dart'; |
| 14 import 'barback_logger.dart'; | |
| 14 import 'group_runner.dart'; | 15 import 'group_runner.dart'; |
| 15 import 'errors.dart'; | 16 import 'errors.dart'; |
| 16 import 'phase_forwarder.dart'; | 17 import 'phase_forwarder.dart'; |
| 17 import 'phase_input.dart'; | 18 import 'phase_input.dart'; |
| 18 import 'phase_output.dart'; | 19 import 'phase_output.dart'; |
| 19 import 'stream_pool.dart'; | 20 import 'stream_pool.dart'; |
| 20 import 'transformer.dart'; | 21 import 'transformer.dart'; |
| 21 import 'transformer_group.dart'; | 22 import 'transformer_group.dart'; |
| 22 import 'utils.dart'; | 23 import 'utils.dart'; |
| 23 | 24 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 | 86 |
| 86 /// A controller whose stream feeds into [_onDirtyPool]. | 87 /// A controller whose stream feeds into [_onDirtyPool]. |
| 87 /// | 88 /// |
| 88 /// This is used whenever an input is added or transforms are changed. | 89 /// This is used whenever an input is added or transforms are changed. |
| 89 final _onDirtyController = new StreamController.broadcast(sync: true); | 90 final _onDirtyController = new StreamController.broadcast(sync: true); |
| 90 | 91 |
| 91 /// Whether this phase is dirty and needs to be run. | 92 /// Whether this phase is dirty and needs to be run. |
| 92 bool get isDirty => _inputs.values.any((input) => input.isDirty) || | 93 bool get isDirty => _inputs.values.any((input) => input.isDirty) || |
| 93 _groups.values.any((group) => group.isDirty); | 94 _groups.values.any((group) => group.isDirty); |
| 94 | 95 |
| 96 /// A stream that emits an event whenever any transforms in this phase log an | |
|
nweiz
2013/10/16 19:41:27
"log" -> "logs"
Bob Nystrom
2013/10/28 23:45:56
Done.
| |
| 97 /// entry. | |
| 98 Stream<LogEntry> get onLog => _onLogPool.stream; | |
| 99 final _onLogPool = new StreamPool<LogEntry>.broadcast(); | |
| 100 | |
| 95 /// The phase after this one. | 101 /// The phase after this one. |
| 96 /// | 102 /// |
| 97 /// Outputs from this phase will be passed to it. | 103 /// Outputs from this phase will be passed to it. |
| 98 Phase get next => _next; | 104 Phase get next => _next; |
| 99 Phase _next; | 105 Phase _next; |
| 100 | 106 |
| 101 /// Returns all currently-available output assets for this phase. | 107 /// Returns all currently-available output assets for this phase. |
| 102 Set<AssetNode> get availableOutputs { | 108 Set<AssetNode> get availableOutputs { |
| 103 return _outputs.values | 109 return _outputs.values |
| 104 .map((output) => output.output) | 110 .map((output) => output.output) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 }); | 150 }); |
| 145 | 151 |
| 146 var input = new PhaseInput(this, node, _transformers); | 152 var input = new PhaseInput(this, node, _transformers); |
| 147 _inputs[node.id] = input; | 153 _inputs[node.id] = input; |
| 148 input.input.whenRemoved.then((_) { | 154 input.input.whenRemoved.then((_) { |
| 149 _inputs.remove(node.id); | 155 _inputs.remove(node.id); |
| 150 _forwarders.remove(node.id).remove(); | 156 _forwarders.remove(node.id).remove(); |
| 151 }); | 157 }); |
| 152 _onDirtyPool.add(input.onDirty); | 158 _onDirtyPool.add(input.onDirty); |
| 153 _onDirtyController.add(null); | 159 _onDirtyController.add(null); |
| 160 _onLogPool.add(input.onLog); | |
| 154 | 161 |
| 155 for (var group in _groups.values) { | 162 for (var group in _groups.values) { |
| 156 group.addInput(node); | 163 group.addInput(node); |
| 157 } | 164 } |
| 158 } | 165 } |
| 159 | 166 |
| 160 /// Gets the asset node for an input [id]. | 167 /// Gets the asset node for an input [id]. |
| 161 /// | 168 /// |
| 162 /// If an input with that ID cannot be found, returns null. | 169 /// If an input with that ID cannot be found, returns null. |
| 163 Future<AssetNode> getInput(AssetId id) { | 170 Future<AssetNode> getInput(AssetId id) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 /// This will remove all the phase's outputs and all following phases. | 238 /// This will remove all the phase's outputs and all following phases. |
| 232 void remove() { | 239 void remove() { |
| 233 removeFollowing(); | 240 removeFollowing(); |
| 234 for (var input in _inputs.values.toList()) { | 241 for (var input in _inputs.values.toList()) { |
| 235 input.remove(); | 242 input.remove(); |
| 236 } | 243 } |
| 237 for (var group in _groups.values) { | 244 for (var group in _groups.values) { |
| 238 group.remove(); | 245 group.remove(); |
| 239 } | 246 } |
| 240 _onDirtyPool.close(); | 247 _onDirtyPool.close(); |
| 248 _onLogPool.close(); | |
| 241 } | 249 } |
| 242 | 250 |
| 243 /// Remove all phases after this one. | 251 /// Remove all phases after this one. |
| 244 void removeFollowing() { | 252 void removeFollowing() { |
| 245 if (_next == null) return; | 253 if (_next == null) return; |
| 246 _next.remove(); | 254 _next.remove(); |
| 247 _next = null; | 255 _next = null; |
| 248 } | 256 } |
| 249 | 257 |
| 250 /// Processes this phase. | 258 /// Processes this phase. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 _outputs[asset.id].add(asset); | 307 _outputs[asset.id].add(asset); |
| 300 } else { | 308 } else { |
| 301 _outputs[asset.id] = new PhaseOutput(this, asset); | 309 _outputs[asset.id] = new PhaseOutput(this, asset); |
| 302 _outputs[asset.id].onAsset.listen((output) { | 310 _outputs[asset.id].onAsset.listen((output) { |
| 303 if (_next != null) _next.addInput(output); | 311 if (_next != null) _next.addInput(output); |
| 304 }, onDone: () => _outputs.remove(asset.id)); | 312 }, onDone: () => _outputs.remove(asset.id)); |
| 305 if (_next != null) _next.addInput(_outputs[asset.id].output); | 313 if (_next != null) _next.addInput(_outputs[asset.id].output); |
| 306 } | 314 } |
| 307 } | 315 } |
| 308 } | 316 } |
| OLD | NEW |