Chromium Code Reviews| Index: runtime/lib/lib_prefix.dart |
| diff --git a/runtime/lib/lib_prefix.dart b/runtime/lib/lib_prefix.dart |
| index 55b47b38bbd846bb950fe9e9675802d19ffd9659..ab1ac7a30f36eaf9d7f62b1f35419f91e7be36c3 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,21 @@ class _LibraryPrefix { |
| if (hasCompleted) { |
| _invalidateDependentCode(); |
| completer.complete(true); |
| - _outstandingLoadRequests.remove(this); |
| + _outstandingLoadRequests.remove(pair); |
| } |
| }); |
| return completer.future; |
| } |
| } |
| -var _outstandingLoadRequests = new HashMap<_LibraryPrefix, Completer>(); |
| - |
| +var _outstandingLoadRequests = new List<List>(); |
|
hausner
2015/11/17 21:24:39
You lose a little documentation because it's no lo
zra
2015/11/17 21:55:47
Done.
|
| // 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 +57,6 @@ _completeDeferredLoads() { |
| prefix._invalidateDependentCode(); |
| completer.complete(true); |
| } |
| - }); |
| + } |
| _outstandingLoadRequests.clear(); |
| } |