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

Unified Diff: sdk/lib/_internal/pub_generated/lib/src/solver/version_queue.dart

Issue 557563002: Store the async-await compiled pub code directly in the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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: sdk/lib/_internal/pub_generated/lib/src/solver/version_queue.dart
diff --git a/sdk/lib/_internal/pub_generated/lib/src/solver/version_queue.dart b/sdk/lib/_internal/pub_generated/lib/src/solver/version_queue.dart
new file mode 100644
index 0000000000000000000000000000000000000000..aa3a85132e2d48d6860fc2e58c7d731f96e1fbe2
--- /dev/null
+++ b/sdk/lib/_internal/pub_generated/lib/src/solver/version_queue.dart
@@ -0,0 +1,42 @@
+library pub.solver.version_queue;
+import 'dart:async';
+import 'dart:collection' show Queue;
+import '../package.dart';
+typedef Future<Iterable<PackageId>> PackageIdGenerator();
+class VersionQueue {
+ Queue<PackageId> _allowed;
+ final PackageIdGenerator _allowedGenerator;
+ PackageId _locked;
+ PackageId get current {
+ if (_locked != null) return _locked;
+ return _allowed.first;
+ }
+ bool get hasFailed => _hasFailed;
+ bool _hasFailed = false;
+ static Future<VersionQueue> create(PackageId locked,
+ PackageIdGenerator allowedGenerator) {
+ var versions = new VersionQueue._(locked, allowedGenerator);
+ if (locked != null) return new Future.value(versions);
+ return versions._calculateAllowed().then((_) => versions);
+ }
+ VersionQueue._(this._locked, this._allowedGenerator);
+ Future<bool> advance() {
+ _hasFailed = false;
+ if (_locked != null) {
+ return _calculateAllowed().then((_) {
+ _locked = null;
+ return _allowed.isNotEmpty;
+ });
+ }
+ _allowed.removeFirst();
+ return new Future.value(_allowed.isNotEmpty);
+ }
+ void fail() {
+ _hasFailed = true;
+ }
+ Future _calculateAllowed() {
+ return _allowedGenerator().then((allowed) {
+ _allowed = new Queue<PackageId>.from(allowed);
+ });
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698