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

Unified Diff: runtime/lib/lib_prefix.dart

Issue 1452053003: Use a List for outstanding load requests (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Added comment Created 5 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 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: runtime/lib/lib_prefix.dart
diff --git a/runtime/lib/lib_prefix.dart b/runtime/lib/lib_prefix.dart
index 55b47b38bbd846bb950fe9e9675802d19ffd9659..4f509da5bff4a23e95cbea1eed136bfcd5357576 100644
--- a/runtime/lib/lib_prefix.dart
+++ b/runtime/lib/lib_prefix.dart
@@ -3,26 +3,28 @@
// BSD-style license that can be found in the LICENSE file.
import "dart:async";
-import "dart:collection";
import "dart:isolate";
// This type corresponds to the VM-internal class LibraryPrefix.
class _LibraryPrefix {
-
bool _load() native "LibraryPrefix_load";
Error _loadError() native "LibraryPrefix_loadError";
bool isLoaded() native "LibraryPrefix_isLoaded";
-
bool _invalidateDependentCode()
native "LibraryPrefix_invalidateDependentCode";
loadLibrary() {
- var completer = _outstandingLoadRequests[this];
- if (completer != null) {
- return completer.future;
+ for (int i = 0; i < _outstandingLoadRequests.length; i++) {
+ if (_outstandingLoadRequests[i][0] == this) {
+ return _outstandingLoadRequests[i][1].future;
+ }
}
- completer = new Completer<bool>();
- _outstandingLoadRequests[this] = completer;
+
+ var completer = new Completer<bool>();
+ var pair = new List();
+ pair.add(this);
+ pair.add(completer);
+ _outstandingLoadRequests.add(pair);
Timer.run(() {
var hasCompleted = this._load();
// Loading can complete immediately, for example when the same
@@ -33,20 +35,23 @@ class _LibraryPrefix {
if (hasCompleted) {
_invalidateDependentCode();
completer.complete(true);
- _outstandingLoadRequests.remove(this);
+ _outstandingLoadRequests.remove(pair);
}
});
return completer.future;
}
}
-var _outstandingLoadRequests = new HashMap<_LibraryPrefix, Completer>();
-
+// A list of two element lists. The first element is the _LibraryPrefix. The
+// second element is the Completer for the load request.
+var _outstandingLoadRequests = new List<List>();
// Called from the VM when all outstanding load requests have
// finished.
_completeDeferredLoads() {
- _outstandingLoadRequests.forEach((prefix, completer) {
+ for (int i = 0; i < _outstandingLoadRequests.length; i++) {
+ var prefix = _outstandingLoadRequests[i][0];
+ var completer = _outstandingLoadRequests[i][1];
var error = prefix._loadError();
if (error != null) {
completer.completeError(error);
@@ -54,6 +59,6 @@ _completeDeferredLoads() {
prefix._invalidateDependentCode();
completer.complete(true);
}
- });
+ }
_outstandingLoadRequests.clear();
}
« 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