OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "dart:async"; | 5 import "dart:async"; |
6 import "dart:isolate"; | 6 import "dart:isolate"; |
7 | 7 |
8 // This type corresponds to the VM-internal class LibraryPrefix. | 8 // This type corresponds to the VM-internal class LibraryPrefix. |
9 class _LibraryPrefix { | 9 class _LibraryPrefix { |
10 bool _load() native "LibraryPrefix_load"; | 10 bool _load() native "LibraryPrefix_load"; |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 }); | 40 }); |
41 return completer.future; | 41 return completer.future; |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 // A list of two element lists. The first element is the _LibraryPrefix. The | 45 // A list of two element lists. The first element is the _LibraryPrefix. The |
46 // second element is the Completer for the load request. | 46 // second element is the Completer for the load request. |
47 var _outstandingLoadRequests = new List<List>(); | 47 var _outstandingLoadRequests = new List<List>(); |
48 | 48 |
49 // Called from the VM when all outstanding load requests have | 49 // Called from the VM when an outstanding load request has finished. |
50 // finished. | |
51 _completeDeferredLoads() { | 50 _completeDeferredLoads() { |
| 51 // Determine which outstanding load requests have completed and complete |
| 52 // their completer (with an error or true). For outstanding load requests |
| 53 // which have not completed, remember them for next time in |
| 54 // stillOutstandingLoadRequests. |
| 55 var stillOutstandingLoadRequests = new List<List>(); |
52 for (int i = 0; i < _outstandingLoadRequests.length; i++) { | 56 for (int i = 0; i < _outstandingLoadRequests.length; i++) { |
53 var prefix = _outstandingLoadRequests[i][0]; | 57 var prefix = _outstandingLoadRequests[i][0]; |
54 var completer = _outstandingLoadRequests[i][1]; | 58 if (prefix._load()) { |
55 var error = prefix._loadError(); | 59 var completer = _outstandingLoadRequests[i][1]; |
56 if (error != null) { | 60 var error = prefix._loadError(); |
57 completer.completeError(error); | 61 if (error != null) { |
| 62 completer.completeError(error); |
| 63 } else { |
| 64 prefix._invalidateDependentCode(); |
| 65 completer.complete(true); |
| 66 } |
58 } else { | 67 } else { |
59 prefix._invalidateDependentCode(); | 68 stillOutstandingLoadRequests.add(_outstandingLoadRequests[i]); |
60 completer.complete(true); | |
61 } | 69 } |
62 } | 70 } |
63 _outstandingLoadRequests.clear(); | 71 _outstandingLoadRequests = stillOutstandingLoadRequests; |
64 } | 72 } |
OLD | NEW |