| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 * isolate. It must be a top-level function or a static method that | 77 * isolate. It must be a top-level function or a static method that |
| 78 * takes one argument - that is, one-parameter functions that can be | 78 * takes one argument - that is, one-parameter functions that can be |
| 79 * compile-time constant function values. | 79 * compile-time constant function values. |
| 80 * It is not allowed to pass the value of function expressions or an instance | 80 * It is not allowed to pass the value of function expressions or an instance |
| 81 * method extracted from an object. | 81 * method extracted from an object. |
| 82 * | 82 * |
| 83 * The entry-point function is invoked with the initial [message]. | 83 * The entry-point function is invoked with the initial [message]. |
| 84 * Usually the initial [message] contains a [SendPort] so | 84 * Usually the initial [message] contains a [SendPort] so |
| 85 * that the spawner and spawnee can communicate with each other. | 85 * that the spawner and spawnee can communicate with each other. |
| 86 * | 86 * |
| 87 * If the [paused] parameter is set to `true`, |
| 88 * the isolate will start up in a paused state, |
| 89 * as if by an initial call of `isolate.pause(isolate.pauseCapability)`. |
| 90 * This allows setting up error or exit listeners on the isolate |
| 91 * before it starts running. |
| 92 * To resume the isolate, call `isolate.resume(isolate.pauseCapability)`. |
| 93 * |
| 94 * WARNING: The `pause` parameter is not implemented on all platforms yet. |
| 95 * |
| 87 * Returns a future that will complete with an [Isolate] instance if the | 96 * Returns a future that will complete with an [Isolate] instance if the |
| 88 * spawning succeeded. It will complete with an error otherwise. | 97 * spawning succeeded. It will complete with an error otherwise. |
| 89 */ | 98 */ |
| 90 external static Future<Isolate> spawn(void entryPoint(message), var message, | 99 external static Future<Isolate> spawn(void entryPoint(message), var message, |
| 91 { bool paused: false }); | 100 { bool paused: false }); |
| 92 | 101 |
| 93 /** | 102 /** |
| 94 * Creates and spawns an isolate that runs the code from the library with | 103 * Creates and spawns an isolate that runs the code from the library with |
| 95 * the specified URI. | 104 * the specified URI. |
| 96 * | 105 * |
| 97 * The isolate starts executing the top-level `main` function of the library | 106 * The isolate starts executing the top-level `main` function of the library |
| 98 * with the given URI. | 107 * with the given URI. |
| 99 * | 108 * |
| 100 * The target `main` must be a subtype of one of these three signatures: | 109 * The target `main` must be a subtype of one of these three signatures: |
| 101 * | 110 * |
| 102 * * `main()` | 111 * * `main()` |
| 103 * * `main(args)` | 112 * * `main(args)` |
| 104 * * `main(args, message)` | 113 * * `main(args, message)` |
| 105 * | 114 * |
| 106 * When present, the parameter `args` is set to the provided [args] list. | 115 * When present, the parameter `args` is set to the provided [args] list. |
| 107 * When present, the parameter `message` is set to the initial [message]. | 116 * When present, the parameter `message` is set to the initial [message]. |
| 108 * | 117 * |
| 118 * If the [packageRoot] parameter is provided, it is used to find the location |
| 119 * of packages imports in the spawned isolate. |
| 120 * The `packageRoot` URI must be a "file" or "http"/"https" URI that specifies |
| 121 * a directory. If it doesn't end in a slash, one will be added before |
| 122 * using the URI, and any query or fragment parts are ignored. |
| 123 * Package imports (like "package:foo/bar.dart") in the new isolate are |
| 124 * resolved against this location, as by |
| 125 * `packageRoot.resolve("foo/bar.dart")`. |
| 126 * This includes the main entry [uri] if it happens to be a package-URL. |
| 127 * If [packageRoot] is omitted, it defaults to the same URI that |
| 128 * the current isolate is using. |
| 129 * |
| 130 * WARNING: The [packageRoot] parameter is not implemented on any |
| 131 * platform yet. |
| 132 * |
| 133 * If the [paused] parameter is set to `true`, |
| 134 * the isolate will start up in a paused state, |
| 135 * as if by an initial call of `isolate.pause(isolate.pauseCapability)`. |
| 136 * This allows setting up error or exit listeners on the isolate |
| 137 * before it starts running. |
| 138 * To resume the isolate, call `isolate.resume(isolate.pauseCapability)`. |
| 139 * |
| 140 * WARNING: The `pause` parameter is not implemented on all platforms yet. |
| 141 * |
| 109 * Returns a future that will complete with an [Isolate] instance if the | 142 * Returns a future that will complete with an [Isolate] instance if the |
| 110 * spawning succeeded. It will complete with an error otherwise. | 143 * spawning succeeded. It will complete with an error otherwise. |
| 111 */ | 144 */ |
| 112 external static Future<Isolate> spawnUri( | 145 external static Future<Isolate> spawnUri( |
| 113 Uri uri, List<String> args, var message, { bool paused: false }); | 146 Uri uri, |
| 147 List<String> args, |
| 148 var message, |
| 149 {bool paused: false, |
| 150 Uri packageRoot}); |
| 114 | 151 |
| 115 /** | 152 /** |
| 116 * Requests the isolate to pause. | 153 * Requests the isolate to pause. |
| 117 * | 154 * |
| 118 * WARNING: This method is experimental and not handled on every platform yet. | 155 * WARNING: This method is experimental and not handled on every platform yet. |
| 119 * | 156 * |
| 120 * The isolate should stop handling events by pausing its event queue. | 157 * The isolate should stop handling events by pausing its event queue. |
| 121 * The request will eventually make the isolate stop doing anything. | 158 * The request will eventually make the isolate stop doing anything. |
| 122 * It will be handled before any other messages that are later sent to the | 159 * It will be handled before any other messages that are later sent to the |
| 123 * isolate from the current isolate, but no other guarantees are provided. | 160 * isolate from the current isolate, but no other guarantees are provided. |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 : _description = description, | 549 : _description = description, |
| 513 stackTrace = new _RemoteStackTrace(stackDescription); | 550 stackTrace = new _RemoteStackTrace(stackDescription); |
| 514 String toString() => _description; | 551 String toString() => _description; |
| 515 } | 552 } |
| 516 | 553 |
| 517 class _RemoteStackTrace implements StackTrace { | 554 class _RemoteStackTrace implements StackTrace { |
| 518 String _trace; | 555 String _trace; |
| 519 _RemoteStackTrace(this._trace); | 556 _RemoteStackTrace(this._trace); |
| 520 String toString() => _trace; | 557 String toString() => _trace; |
| 521 } | 558 } |
| OLD | NEW |