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.transform_node; | 5 library barback.transform_node; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'asset.dart'; | 9 import 'asset.dart'; |
10 import 'asset_id.dart'; | 10 import 'asset_id.dart'; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 var transform = createTransform(this, newOutputs, _log); | 118 var transform = createTransform(this, newOutputs, _log); |
119 | 119 |
120 // Clear all the old input subscriptions. If an input is re-used, we'll | 120 // Clear all the old input subscriptions. If an input is re-used, we'll |
121 // re-subscribe. | 121 // re-subscribe. |
122 for (var subscription in _inputSubscriptions.values) { | 122 for (var subscription in _inputSubscriptions.values) { |
123 subscription.cancel(); | 123 subscription.cancel(); |
124 } | 124 } |
125 _inputSubscriptions.clear(); | 125 _inputSubscriptions.clear(); |
126 | 126 |
127 _isDirty = false; | 127 _isDirty = false; |
128 return transformer.apply(transform).catchError((error) { | 128 |
129 return phase.cascade.graph.transformerPool.checkOut().then((item) { | |
Alan Knight
2013/10/23 00:24:06
That seems like a rather awkward way to get to the
nweiz
2013/10/23 04:11:25
I agree. I'm planning a refactor that will make th
| |
130 return transformer.apply(transform).whenComplete(item.release); | |
Alan Knight
2013/10/23 00:24:06
Is it worth defining a pool API that automatically
nweiz
2013/10/23 04:11:25
Done.
| |
131 }).catchError((error) { | |
129 // If the transform became dirty while processing, ignore any errors from | 132 // If the transform became dirty while processing, ignore any errors from |
130 // it. | 133 // it. |
131 if (_isDirty) return; | 134 if (_isDirty) return; |
132 | 135 |
133 if (error is! MissingInputException) { | 136 if (error is! MissingInputException) { |
134 error = new TransformerException(info, error); | 137 error = new TransformerException(info, error); |
135 } | 138 } |
136 | 139 |
137 // Catch all transformer errors and pipe them to the results stream. | 140 // Catch all transformer errors and pipe them to the results stream. |
138 // This is so a broken transformer doesn't take down the whole graph. | 141 // This is so a broken transformer doesn't take down the whole graph. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 } | 214 } |
212 | 215 |
213 void _log(AssetId asset, LogLevel level, String message, Span span) { | 216 void _log(AssetId asset, LogLevel level, String message, Span span) { |
214 // If the log isn't already associated with an asset, use the primary. | 217 // If the log isn't already associated with an asset, use the primary. |
215 if (asset == null) asset = primary.id; | 218 if (asset == null) asset = primary.id; |
216 var info = new TransformInfo(transformer, primary.id); | 219 var info = new TransformInfo(transformer, primary.id); |
217 var entry = new LogEntry(info, asset, level, message, span); | 220 var entry = new LogEntry(info, asset, level, message, span); |
218 _onLogController.add(entry); | 221 _onLogController.add(entry); |
219 } | 222 } |
220 } | 223 } |
OLD | NEW |