Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * Concurrent programming using _isolates_: | 6 * Concurrent programming using _isolates_: |
| 7 * independent workers that are similar to threads | 7 * independent workers that are similar to threads |
| 8 * but don't share memory, | 8 * but don't share memory, |
| 9 * communicating only via messages. | 9 * communicating only via messages. |
| 10 */ | 10 */ |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 /** | 120 /** |
| 121 * Return the current [Isolate]. | 121 * Return the current [Isolate]. |
| 122 * | 122 * |
| 123 * The isolate gives access to the capabilities needed to inspect, | 123 * The isolate gives access to the capabilities needed to inspect, |
| 124 * pause or kill the isolate, and allows granting these capabilities | 124 * pause or kill the isolate, and allows granting these capabilities |
| 125 * to others. | 125 * to others. |
| 126 */ | 126 */ |
| 127 external static Isolate get current; | 127 external static Isolate get current; |
| 128 | 128 |
| 129 /** | 129 /** |
| 130 * Returns the package root of the current isolate, if any. | |
| 131 * | |
| 132 * If the isolate is using a [packageConfig] or the isolate has not been | |
| 133 * setup for package resolution, this getter returns `null`, otherwise it | |
| 134 * returns the package root - a directory that package URIs are resolved | |
| 135 * against. | |
| 136 */ | |
| 137 external static Future<Uri> get packageRoot; | |
| 138 | |
| 139 /** | |
| 140 * Returns the package root of the current isolate, if any. | |
| 141 * | |
| 142 * If the isolate is using a [packageRoot] or the isolate has not been | |
| 143 * setup for package resolution, this getter returns `null`, otherwise it | |
| 144 * returns the package config URI. | |
| 145 */ | |
| 146 external static Future<Uri> get packageConfig; | |
| 147 | |
| 148 /** | |
| 149 * Maps a package: URI to a non-package Uri. | |
| 150 * | |
| 151 * If there is no valid mapping from the package: URI in the current | |
| 152 * isolate, then this call returns `null`. Non-package: URIs are | |
| 153 * returned unmodified. | |
| 154 */ | |
| 155 external static Future<Uri> resolvePackageUri(Uri packageUri); | |
| 156 | |
| 157 /** | |
| 130 * Creates and spawns an isolate that shares the same code as the current | 158 * Creates and spawns an isolate that shares the same code as the current |
| 131 * isolate. | 159 * isolate. |
| 132 * | 160 * |
| 133 * The argument [entryPoint] specifies the entry point of the spawned | 161 * The argument [entryPoint] specifies the entry point of the spawned |
| 134 * isolate. It must be a top-level function or a static method that | 162 * isolate. It must be a top-level function or a static method that |
| 135 * takes one argument - that is, one-parameter functions that can be | 163 * takes one argument - that is, one-parameter functions that can be |
| 136 * compile-time constant function values. | 164 * compile-time constant function values. |
| 137 * It is not allowed to pass the value of function expressions or an instance | 165 * It is not allowed to pass the value of function expressions or an instance |
| 138 * method extracted from an object. | 166 * method extracted from an object. |
| 139 * | 167 * |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 * If the [packageRoot] parameter is provided, it is used to find the location | 243 * If the [packageRoot] parameter is provided, it is used to find the location |
| 216 * of package sources in the spawned isolate. | 244 * of package sources in the spawned isolate. |
| 217 * | 245 * |
| 218 * The `packageRoot` URI must be a "file" or "http"/"https" URI that specifies | 246 * The `packageRoot` URI must be a "file" or "http"/"https" URI that specifies |
| 219 * a directory. If it doesn't end in a slash, one will be added before | 247 * a directory. If it doesn't end in a slash, one will be added before |
| 220 * using the URI, and any query or fragment parts are ignored. | 248 * using the URI, and any query or fragment parts are ignored. |
| 221 * Package imports (like `"package:foo/bar.dart"`) in the new isolate are | 249 * Package imports (like `"package:foo/bar.dart"`) in the new isolate are |
| 222 * resolved against this location, as by | 250 * resolved against this location, as by |
| 223 * `packageRoot.resolve("foo/bar.dart")`. | 251 * `packageRoot.resolve("foo/bar.dart")`. |
| 224 * | 252 * |
| 253 * If the [packageConfig] parameter is provided, then it is used to find the | |
| 254 * location of a package resolution configuration file for the spawned | |
| 255 * isolate. | |
| 256 * | |
|
kevmoo
2016/01/13 02:21:19
Need notes on the behavior if both `packageRoot` a
| |
| 257 * If the [automaticPackageResolution] parameter is provided, then the | |
|
kevmoo
2016/01/13 02:21:19
provided => `true`.
| |
| 258 * location of the package sources in the spawned isolate is automatically | |
| 259 * determined. | |
|
kevmoo
2016/01/13 02:21:19
determined how?
How does this relate to packageRo
| |
| 260 * | |
| 225 * The [environment] is a mapping from strings to strings which the | 261 * The [environment] is a mapping from strings to strings which the |
| 226 * spawned isolate uses when looking up [String.fromEnvironment] values. | 262 * spawned isolate uses when looking up [String.fromEnvironment] values. |
| 227 * The system may add its own entries to environment as well. | 263 * The system may add its own entries to environment as well. |
| 228 * If `environment` is omitted, the spawned isolate has the same environment | 264 * If `environment` is omitted, the spawned isolate has the same environment |
| 229 * declarations as the spawning isolate. | 265 * declarations as the spawning isolate. |
| 230 * | 266 * |
| 231 * WARNING: The [environment] parameter is not implemented on all | 267 * WARNING: The [environment] parameter is not implemented on all |
| 232 * platforms yet. | 268 * platforms yet. |
| 233 * | 269 * |
| 234 * Returns a future that will complete with an [Isolate] instance if the | 270 * Returns a future that will complete with an [Isolate] instance if the |
| 235 * spawning succeeded. It will complete with an error otherwise. | 271 * spawning succeeded. It will complete with an error otherwise. |
| 236 */ | 272 */ |
| 237 external static Future<Isolate> spawnUri( | 273 external static Future<Isolate> spawnUri( |
| 238 Uri uri, | 274 Uri uri, |
| 239 List<String> args, | 275 List<String> args, |
| 240 var message, | 276 var message, |
| 241 {bool paused: false, | 277 {bool paused: false, |
| 242 SendPort onExit, | 278 SendPort onExit, |
| 243 SendPort onError, | 279 SendPort onError, |
| 244 bool errorsAreFatal, | 280 bool errorsAreFatal, |
| 245 bool checked, | 281 bool checked, |
| 246 Map<String, String> environment, | 282 Map<String, String> environment, |
| 247 Uri packageRoot}); | 283 Uri packageRoot, |
| 284 Uri packageConfig, | |
| 285 bool automaticPackageResolution: false}); | |
| 248 | 286 |
| 249 /** | 287 /** |
| 250 * Requests the isolate to pause. | 288 * Requests the isolate to pause. |
| 251 * | 289 * |
| 252 * The isolate should stop handling events by pausing its event queue. | 290 * The isolate should stop handling events by pausing its event queue. |
| 253 * The request will eventually make the isolate stop doing anything. | 291 * The request will eventually make the isolate stop doing anything. |
| 254 * It will be handled before any other messages that are later sent to the | 292 * It will be handled before any other messages that are later sent to the |
| 255 * isolate from the current isolate, but no other guarantees are provided. | 293 * isolate from the current isolate, but no other guarantees are provided. |
| 256 * | 294 * |
| 257 * The event loop may be paused before previously sent, but not yet exeuted, | 295 * The event loop may be paused before previously sent, but not yet exeuted, |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 * as the original error, but has no other features of the original error. | 652 * as the original error, but has no other features of the original error. |
| 615 */ | 653 */ |
| 616 class RemoteError implements Error { | 654 class RemoteError implements Error { |
| 617 final String _description; | 655 final String _description; |
| 618 final StackTrace stackTrace; | 656 final StackTrace stackTrace; |
| 619 RemoteError(String description, String stackDescription) | 657 RemoteError(String description, String stackDescription) |
| 620 : _description = description, | 658 : _description = description, |
| 621 stackTrace = new StackTrace.fromString(stackDescription); | 659 stackTrace = new StackTrace.fromString(stackDescription); |
| 622 String toString() => _description; | 660 String toString() => _description; |
| 623 } | 661 } |
| OLD | NEW |