Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: pkg/barback/lib/src/transform_node.dart

Issue 231603005: Preserve laziness in declaring transformers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/barback/lib/src/phase.dart ('k') | pkg/barback/test/package_graph/lazy_transformer_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/transform_node.dart
diff --git a/pkg/barback/lib/src/transform_node.dart b/pkg/barback/lib/src/transform_node.dart
index ecd8d8f677f6b481fc6ca1b586bab96a51542974..2269344d5eb0a3b2620761bd636e3df2fe712932 100644
--- a/pkg/barback/lib/src/transform_node.dart
+++ b/pkg/barback/lib/src/transform_node.dart
@@ -47,7 +47,11 @@ class TransformNode {
/// Whether [this] is dirty and still has more processing to do.
bool get isDirty => _state != _State.NOT_PRIMARY && _state != _State.APPLIED;
- /// Whether [transformer] is lazy and this transform has yet to be forced.
+ /// Whether this transform is lazy and this transform has yet to be forced.
+ ///
+ /// A transform being lazy is distinct from a transformer being lazy. A
+ /// transformer that's declaring but not lazy will have lazy transforms for
+ /// primary inputs that are themselves lazy.
bool _isLazy;
/// The subscriptions to each input's [AssetNode.onStateChange] stream.
@@ -114,12 +118,16 @@ class TransformNode {
/// [declareOutputs] has been run successfully.
Set<AssetId> _declaredOutputs;
- TransformNode(this.phase, Transformer transformer, this.primary,
+ TransformNode(this.phase, Transformer transformer, AssetNode primary,
this._location)
: transformer = transformer,
- _isLazy = transformer is LazyTransformer {
+ primary = primary,
+ _isLazy = transformer is LazyTransformer ||
+ (transformer is DeclaringTransformer && primary.isLazy) {
_onLogPool.add(_onLogController.stream);
+ if (!_isLazy) primary.force();
+
_primarySubscription = primary.onStateChange.listen((state) {
if (state.isRemoved) {
remove();
@@ -167,6 +175,7 @@ class TransformNode {
// TODO(nweiz): we might want to have a timeout after which, if the
// transform's outputs have gone unused, we switch it back to lazy mode.
if (!_isLazy) return;
+ primary.force();
_isLazy = false;
_dirty();
}
@@ -253,7 +262,7 @@ class TransformNode {
if (!_declaredOutputs.contains(primary.id)) _emitPassThrough();
for (var id in _declaredOutputs) {
- var controller = transformer is LazyTransformer
+ var controller = _isLazy
? new AssetNodeController.lazy(id, force, this)
: new AssetNodeController(id, this);
_outputControllers[id] = controller;
« no previous file with comments | « pkg/barback/lib/src/phase.dart ('k') | pkg/barback/test/package_graph/lazy_transformer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698