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

Side by Side Diff: pkg/barback/lib/src/phase_output.dart

Issue 36463002: Fix a synchrony bug in barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_output; 5 library barback.phase_output;
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';
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 /// a new [Phase] to cause consumers of the prior phase's outputs to be to 75 /// a new [Phase] to cause consumers of the prior phase's outputs to be to
76 /// start consuming the new phase's outputs instead. 76 /// start consuming the new phase's outputs instead.
77 void removeListeners() { 77 void removeListeners() {
78 _outputForwarder.close(); 78 _outputForwarder.close();
79 _outputForwarder = new AssetForwarder(_assets.first); 79 _outputForwarder = new AssetForwarder(_assets.first);
80 _onAssetController.add(output); 80 _onAssetController.add(output);
81 } 81 }
82 82
83 /// Watches [node] to adjust [_assets] and [output] when it's removed. 83 /// Watches [node] to adjust [_assets] and [output] when it's removed.
84 void _watchAsset(AssetNode node) { 84 void _watchAsset(AssetNode node) {
85 node.whenRemoved.then((_) { 85 node.whenRemoved(() {
86 if (_assets.length == 1) { 86 if (_assets.length == 1) {
87 assert(_assets.single == node); 87 assert(_assets.single == node);
88 _outputForwarder.close(); 88 _outputForwarder.close();
89 _onAssetController.close(); 89 _onAssetController.close();
90 return; 90 return;
91 } 91 }
92 92
93 // If there was more than one asset, we're resolving a collision -- 93 // If there was more than one asset, we're resolving a collision --
94 // possibly partially. 94 // possibly partially.
95 var wasFirst = _assets.first == node; 95 var wasFirst = _assets.first == node;
96 _assets.remove(node); 96 _assets.remove(node);
97 97
98 // If this was the first asset, we replace it with the next asset 98 // If this was the first asset, we replace it with the next asset
99 // (chronologically). 99 // (chronologically).
100 if (wasFirst) removeListeners(); 100 if (wasFirst) removeListeners();
101 101
102 // If there's still a collision, report it. This lets the user know if 102 // If there's still a collision, report it. This lets the user know if
103 // they've successfully resolved the collision or not. 103 // they've successfully resolved the collision or not.
104 if (_assets.length > 1) { 104 if (_assets.length > 1) {
105 // Pump the event queue to ensure that the removal of the input triggers 105 // Pump the event queue to ensure that the removal of the input triggers
106 // a new build to which we can attach the error. 106 // a new build to which we can attach the error.
107 // TODO(nweiz): report this through the output asset. 107 // TODO(nweiz): report this through the output asset.
108 newFuture(() => _phase.cascade.reportError(collisionException)); 108 newFuture(() => _phase.cascade.reportError(collisionException));
109 } 109 }
110 }); 110 });
111 } 111 }
112 } 112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698