| 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.graph.group_runner; | 5 library barback.graph.group_runner; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import '../asset/asset_node.dart'; | 9 import '../asset/asset_node.dart'; |
| 10 import '../log.dart'; | 10 import '../log.dart'; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 /// Assets are emitted synchronously to ensure that any changes are thoroughly | 43 /// Assets are emitted synchronously to ensure that any changes are thoroughly |
| 44 /// propagated as soon as they occur. | 44 /// propagated as soon as they occur. |
| 45 Stream<AssetNode> get onAsset => _onAsset; | 45 Stream<AssetNode> get onAsset => _onAsset; |
| 46 Stream<AssetNode> _onAsset; | 46 Stream<AssetNode> _onAsset; |
| 47 | 47 |
| 48 /// A stream that emits an event whenever any transforms in this group logs | 48 /// A stream that emits an event whenever any transforms in this group logs |
| 49 /// an entry. | 49 /// an entry. |
| 50 Stream<LogEntry> get onLog => _onLogPool.stream; | 50 Stream<LogEntry> get onLog => _onLogPool.stream; |
| 51 final _onLogPool = new StreamPool<LogEntry>.broadcast(); | 51 final _onLogPool = new StreamPool<LogEntry>.broadcast(); |
| 52 | 52 |
| 53 GroupRunner(AssetCascade cascade, this._group, this._location) { | 53 GroupRunner(Phase previous, this._group, this._location) { |
| 54 _addPhase(new Phase(cascade, _location), []); | 54 _addPhase(previous.addPhase(_location), []); |
| 55 for (var phase in _group.phases) { | 55 for (var phase in _group.phases) { |
| 56 _addPhase(_phases.last.addPhase(), phase); | 56 _addPhase(_phases.last.addPhase(), phase); |
| 57 } | 57 } |
| 58 | 58 |
| 59 _onAsset = _phases.last.onAsset; | 59 _onAsset = _phases.last.onAsset; |
| 60 _onStatusChange = _phases.last.onStatusChange; | 60 _onStatusChange = _phases.last.onStatusChange; |
| 61 } | 61 } |
| 62 | 62 |
| 63 /// Add a phase with [contents] to [this]'s list of phases. | 63 /// Add a phase with [contents] to [this]'s list of phases. |
| 64 /// | 64 /// |
| 65 /// [contents] should be an inner [Iterable] from a [TransformGroup.phases] | 65 /// [contents] should be an inner [Iterable] from a [TransformGroup.phases] |
| 66 /// value. | 66 /// value. |
| 67 void _addPhase(Phase phase, Iterable contents) { | 67 void _addPhase(Phase phase, Iterable contents) { |
| 68 _phases.add(phase); | 68 _phases.add(phase); |
| 69 _onLogPool.add(phase.onLog); | 69 _onLogPool.add(phase.onLog); |
| 70 phase.updateTransformers(contents); | 70 phase.updateTransformers(contents); |
| 71 } | 71 } |
| 72 | 72 |
| 73 /// Force all [LazyTransformer]s' transforms in this group to begin producing | 73 /// Force all [LazyTransformer]s' transforms in this group to begin producing |
| 74 /// concrete assets. | 74 /// concrete assets. |
| 75 void forceAllTransforms() { | 75 void forceAllTransforms() { |
| 76 for (var phase in _phases) { | 76 for (var phase in _phases) { |
| 77 phase.forceAllTransforms(); | 77 phase.forceAllTransforms(); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 /// Adds a new asset as an input for this group. | |
| 82 void addInput(AssetNode node) { | |
| 83 _phases.first.addInput(node); | |
| 84 } | |
| 85 | |
| 86 /// Removes this group and all sub-phases within it. | 81 /// Removes this group and all sub-phases within it. |
| 87 void remove() { | 82 void remove() { |
| 88 _onLogPool.close(); | 83 _onLogPool.close(); |
| 89 for (var phase in _phases) { | 84 for (var phase in _phases) { |
| 90 phase.remove(); | 85 phase.remove(); |
| 91 } | 86 } |
| 92 } | 87 } |
| 93 | 88 |
| 94 String toString() => "group in phase $_location for $_group"; | 89 String toString() => "group in phase $_location for $_group"; |
| 95 } | 90 } |
| OLD | NEW |