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

Unified Diff: pkg/barback/lib/src/phase_input.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, 2 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
Index: pkg/barback/lib/src/phase_input.dart
diff --git a/pkg/barback/lib/src/phase_input.dart b/pkg/barback/lib/src/phase_input.dart
index 10970221ee62e8b3e491ac19d37c1a0fa54f762a..552fa5daf9f5a7b1e536eaca2561db24d56cf1f9 100644
--- a/pkg/barback/lib/src/phase_input.dart
+++ b/pkg/barback/lib/src/phase_input.dart
@@ -275,14 +275,19 @@ class PhaseInput {
/// Processes the transforms for this input.
Future<Set<AssetNode>> process() {
if (_adjustTransformersFuture == null) return _processTransforms();
- return _waitForInputs().then((_) => _processTransforms());
+ return _waitForTransformers(() => _processTransforms());
}
- Future _waitForInputs() {
- // Return a synchronous future so we can be sure [_adjustTransformers] isn't
- // called between now and when the Future completes.
- if (_adjustTransformersFuture == null) return new Future.sync(() {});
- return _adjustTransformersFuture.then((_) => _waitForInputs());
+ /// Runs [callback] once all the transformers are adjusted correctly and the
+ /// input is ready to be processed.
+ ///
+ /// If the transformers are already properly adjusted, [callback] is called
+ /// synchronously to ensure that [_adjustTransformers] isn't called before the
+ /// callback.
+ Future _waitForTransformers(callback()) {
+ if (_adjustTransformersFuture == null) return new Future.sync(callback);
+ return _adjustTransformersFuture.then(
+ (_) => _waitForTransformers(callback));
}
/// Applies all currently wired up and dirty transforms.

Powered by Google App Engine
This is Rietveld 408576698