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 [packageMap], this getter returns `null`, | |
133 * otherwise it returns the package root - a directory that package | |
134 * URIs are resolved against. | |
135 */ | |
136 external static Future<Uri> get packageRoot; | |
137 | |
138 /** | |
139 * Returns the package mapping of the current isolate, if any. | |
140 * | |
141 * If the current isolate is using a [packageRoot], this getter | |
142 * returns `null`. | |
143 * | |
144 * The package map maps the name of a package that is available to the | |
145 * program, to a URI that package URIs for that package are resolved against. | |
146 * | |
147 * Returns an empty map if the isolate does not have a way to resolve package | |
148 * URIs. | |
149 */ | |
150 external static Future<Map<String, Uri>> get packageMap; | |
151 | |
152 /** | |
153 * Creates and spawns an isolate that shares the same code as the current | 130 * Creates and spawns an isolate that shares the same code as the current |
154 * isolate. | 131 * isolate. |
155 * | 132 * |
156 * The argument [entryPoint] specifies the entry point of the spawned | 133 * The argument [entryPoint] specifies the entry point of the spawned |
157 * isolate. It must be a top-level function or a static method that | 134 * isolate. It must be a top-level function or a static method that |
158 * takes one argument - that is, one-parameter functions that can be | 135 * takes one argument - that is, one-parameter functions that can be |
159 * compile-time constant function values. | 136 * compile-time constant function values. |
160 * It is not allowed to pass the value of function expressions or an instance | 137 * It is not allowed to pass the value of function expressions or an instance |
161 * method extracted from an object. | 138 * method extracted from an object. |
162 * | 139 * |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 * If the parameter is omitted, the new isolate will inherit the | 205 * If the parameter is omitted, the new isolate will inherit the |
229 * value from the current isolate. | 206 * value from the current isolate. |
230 * | 207 * |
231 * It may not always be possible to honor the `checked` parameter. | 208 * It may not always be possible to honor the `checked` parameter. |
232 * If the isolate code was pre-compiled, it may not be possible to change | 209 * If the isolate code was pre-compiled, it may not be possible to change |
233 * the checked mode setting dynamically. | 210 * the checked mode setting dynamically. |
234 * In that case, the `checked` parameter is ignored. | 211 * In that case, the `checked` parameter is ignored. |
235 * | 212 * |
236 * WARNING: The [checked] parameter is not implemented on all platforms yet. | 213 * WARNING: The [checked] parameter is not implemented on all platforms yet. |
237 * | 214 * |
238 * If either the [packageRoot] or the [packageMap] parameter is provided, | 215 * If the [packageRoot] parameter is provided, it is used to find the location |
239 * it is used to find the location of package sources in the spawned isolate. | 216 * of package sources in the spawned isolate. |
240 * | 217 * |
241 * The `packageRoot` URI must be a "file" or "http"/"https" URI that specifies | 218 * The `packageRoot` URI must be a "file" or "http"/"https" URI that specifies |
242 * a directory. If it doesn't end in a slash, one will be added before | 219 * a directory. If it doesn't end in a slash, one will be added before |
243 * using the URI, and any query or fragment parts are ignored. | 220 * using the URI, and any query or fragment parts are ignored. |
244 * Package imports (like `"package:foo/bar.dart"`) in the new isolate are | 221 * Package imports (like `"package:foo/bar.dart"`) in the new isolate are |
245 * resolved against this location, as by | 222 * resolved against this location, as by |
246 * `packageRoot.resolve("foo/bar.dart")`. | 223 * `packageRoot.resolve("foo/bar.dart")`. |
247 * | 224 * |
248 * The `packageMap` map maps package names to URIs with the same requirements | |
249 * as `packageRoot`. Package imports (like `"package:foo/bar/baz.dart"`) in | |
250 * the new isolate are resolved against the URI for that package (if any), | |
251 * as by `packages["foo"].resolve("bar/baz.dart") | |
252 * | |
253 * This resolution also applies to the main entry [uri] | |
254 * if that happens to be a package-URI. | |
255 * | |
256 * If both [packageRoot] and [packageMap] are omitted, the new isolate uses | |
257 * the same package resolution as the current isolate. | |
258 * It's not allowed to provide both a `packageRoot` and a `package` parameter. | |
259 * | |
260 * WARNING: The [packageRoot] and [packageMap] parameters are not implemented | |
261 * on all platforms yet. | |
262 * | |
263 * The [environment] is a mapping from strings to strings which the | 225 * The [environment] is a mapping from strings to strings which the |
264 * spawned isolate uses when looking up [String.fromEnvironment] values. | 226 * spawned isolate uses when looking up [String.fromEnvironment] values. |
265 * The system may add its own entries to environment as well. | 227 * The system may add its own entries to environment as well. |
266 * If `environment` is omitted, the spawned isolate has the same environment | 228 * If `environment` is omitted, the spawned isolate has the same environment |
267 * declarations as the spawning isolate. | 229 * declarations as the spawning isolate. |
268 * | 230 * |
269 * WARNING: The [environment] parameter is not implemented on all | 231 * WARNING: The [environment] parameter is not implemented on all |
270 * platforms yet. | 232 * platforms yet. |
271 * | 233 * |
272 * Returns a future that will complete with an [Isolate] instance if the | 234 * Returns a future that will complete with an [Isolate] instance if the |
273 * spawning succeeded. It will complete with an error otherwise. | 235 * spawning succeeded. It will complete with an error otherwise. |
274 */ | 236 */ |
275 external static Future<Isolate> spawnUri( | 237 external static Future<Isolate> spawnUri( |
276 Uri uri, | 238 Uri uri, |
277 List<String> args, | 239 List<String> args, |
278 var message, | 240 var message, |
279 {bool paused: false, | 241 {bool paused: false, |
280 SendPort onExit, | 242 SendPort onExit, |
281 SendPort onError, | 243 SendPort onError, |
282 bool errorsAreFatal, | 244 bool errorsAreFatal, |
283 bool checked, | 245 bool checked, |
284 Map<String, String> environment, | 246 Map<String, String> environment, |
285 Uri packageRoot, | 247 Uri packageRoot}); |
286 Map<String, Uri> packageMap}); | |
287 | 248 |
288 /** | 249 /** |
289 * Requests the isolate to pause. | 250 * Requests the isolate to pause. |
290 * | 251 * |
291 * The isolate should stop handling events by pausing its event queue. | 252 * The isolate should stop handling events by pausing its event queue. |
292 * The request will eventually make the isolate stop doing anything. | 253 * The request will eventually make the isolate stop doing anything. |
293 * It will be handled before any other messages that are later sent to the | 254 * It will be handled before any other messages that are later sent to the |
294 * isolate from the current isolate, but no other guarantees are provided. | 255 * isolate from the current isolate, but no other guarantees are provided. |
295 * | 256 * |
296 * The event loop may be paused before previously sent, but not yet exeuted, | 257 * 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... |
653 * as the original error, but has no other features of the original error. | 614 * as the original error, but has no other features of the original error. |
654 */ | 615 */ |
655 class RemoteError implements Error { | 616 class RemoteError implements Error { |
656 final String _description; | 617 final String _description; |
657 final StackTrace stackTrace; | 618 final StackTrace stackTrace; |
658 RemoteError(String description, String stackDescription) | 619 RemoteError(String description, String stackDescription) |
659 : _description = description, | 620 : _description = description, |
660 stackTrace = new StackTrace.fromString(stackDescription); | 621 stackTrace = new StackTrace.fromString(stackDescription); |
661 String toString() => _description; | 622 String toString() => _description; |
662 } | 623 } |
OLD | NEW |