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

Unified Diff: sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart

Issue 1127863002: Don't let the version solver starve the event queue. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
diff --git a/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart b/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
index 73dfd5c4ec640d843de82bd5b77f186543d17ed0..ecea2cd00d9650184acf5d44b61701d08fb62bbc 100644
--- a/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
+++ b/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart
@@ -251,20 +251,19 @@ class BacktrackingSolver {
/// If there are no more versions, continues to backtrack to previous
/// selections, and so on. If there is nothing left to backtrack to,
/// completes to the last failure that occurred.
- Future<List<PackageId>> _traverseSolution() => resetStack(() {
- return new Traverser(this).traverse().catchError((error) {
- if (error is! SolveFailure) throw error;
-
- return _backtrack(error).then((canTry) {
- if (canTry) {
- _attemptedSolutions++;
- return _traverseSolution();
- }
-
- // All out of solutions, so fail.
- throw error;
- });
- });
+ Future<List<PackageId>> _traverseSolution() => resetStack(() async {
+ // Avoid starving the event queue by waiting for a timer-level event.
+ await new Future(() {});
+
+ try {
+ return await new Traverser(this).traverse();
+ } on SolveFailure catch (error) {
+ // All out of solutions, so fail.
+ if (!(await _backtrack(error))) rethrow;
+
+ _attemptedSolutions++;
+ await _traverseSolution();
+ }
});
/// Backtracks from the current failed solution and determines the next
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698