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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 * Usually the initial [message] contains a [SendPort] so | 141 * Usually the initial [message] contains a [SendPort] so |
142 * that the spawner and spawnee can communicate with each other. | 142 * that the spawner and spawnee can communicate with each other. |
143 * | 143 * |
144 * If the [paused] parameter is set to `true`, | 144 * If the [paused] parameter is set to `true`, |
145 * the isolate will start up in a paused state, | 145 * the isolate will start up in a paused state, |
146 * as if by an initial call of `isolate.pause(isolate.pauseCapability)`. | 146 * as if by an initial call of `isolate.pause(isolate.pauseCapability)`. |
147 * This allows setting up error or exit listeners on the isolate | 147 * This allows setting up error or exit listeners on the isolate |
148 * before it starts running. | 148 * before it starts running. |
149 * To resume the isolate, call `isolate.resume(isolate.pauseCapability)`. | 149 * To resume the isolate, call `isolate.resume(isolate.pauseCapability)`. |
150 * | 150 * |
151 * WARNING: The `pause` parameter is not implemented on all platforms yet. | |
152 * | |
153 * Returns a future that will complete with an [Isolate] instance if the | 151 * Returns a future that will complete with an [Isolate] instance if the |
154 * spawning succeeded. It will complete with an error otherwise. | 152 * spawning succeeded. It will complete with an error otherwise. |
155 */ | 153 */ |
156 external static Future<Isolate> spawn(void entryPoint(message), var message, | 154 external static Future<Isolate> spawn(void entryPoint(message), var message, |
157 { bool paused: false }); | 155 { bool paused: false }); |
158 | 156 |
159 /** | 157 /** |
160 * Creates and spawns an isolate that runs the code from the library with | 158 * Creates and spawns an isolate that runs the code from the library with |
161 * the specified URI. | 159 * the specified URI. |
162 * | 160 * |
163 * The isolate starts executing the top-level `main` function of the library | 161 * The isolate starts executing the top-level `main` function of the library |
164 * with the given URI. | 162 * with the given URI. |
165 * | 163 * |
166 * The target `main` must be a subtype of one of these three signatures: | 164 * The target `main` must be a subtype of one of these three signatures: |
167 * | 165 * |
168 * * `main()` | 166 * * `main()` |
169 * * `main(args)` | 167 * * `main(args)` |
170 * * `main(args, message)` | 168 * * `main(args, message)` |
171 * | 169 * |
172 * When present, the parameter `args` is set to the provided [args] list. | 170 * When present, the parameter `args` is set to the provided [args] list. |
173 * When present, the parameter `message` is set to the initial [message]. | 171 * When present, the parameter `message` is set to the initial [message]. |
174 * | 172 * |
| 173 * If the [paused] parameter is set to `true`, |
| 174 * the isolate will start up in a paused state, |
| 175 * as if by an initial call of `isolate.pause(isolate.pauseCapability)`. |
| 176 * This allows setting up error or exit listeners on the isolate |
| 177 * before it starts running. |
| 178 * To resume the isolate, call `isolate.resume(isolate.pauseCapability)`. |
| 179 * |
| 180 * If the [checked] parameter is set to `true` or `false`, |
| 181 * the new isolate will run code in checked mode, |
| 182 * respectively in production mode, if possible. |
| 183 * If the parameter is omitted, the new isolate will inherit the |
| 184 * value from the current isolate. |
| 185 * |
| 186 * It may not always be possible to honor the `checked` parameter. |
| 187 * If the isolate code was pre-compiled, it may not be possible to change |
| 188 * the checked mode setting dynamically. |
| 189 * In that case, the `checked` parameter is ignored. |
| 190 * |
| 191 * WARNING: The [checked] parameter is not implemented on all platforms yet. |
| 192 * |
175 * If the [packageRoot] parameter is provided, it is used to find the location | 193 * If the [packageRoot] parameter is provided, it is used to find the location |
176 * of packages imports in the spawned isolate. | 194 * of packages imports in the spawned isolate. |
177 * The `packageRoot` URI must be a "file" or "http"/"https" URI that specifies | 195 * The `packageRoot` URI must be a "file" or "http"/"https" URI that specifies |
178 * a directory. If it doesn't end in a slash, one will be added before | 196 * a directory. If it doesn't end in a slash, one will be added before |
179 * using the URI, and any query or fragment parts are ignored. | 197 * using the URI, and any query or fragment parts are ignored. |
180 * Package imports (like "package:foo/bar.dart") in the new isolate are | 198 * Package imports (like "package:foo/bar.dart") in the new isolate are |
181 * resolved against this location, as by | 199 * resolved against this location, as by |
182 * `packageRoot.resolve("foo/bar.dart")`. | 200 * `packageRoot.resolve("foo/bar.dart")`. |
183 * This includes the main entry [uri] if it happens to be a package-URL. | 201 * This includes the main entry [uri] if it happens to be a package-URL. |
184 * If [packageRoot] is omitted, it defaults to the same URI that | 202 * If [packageRoot] is omitted, it defaults to the same URI that |
185 * the current isolate is using. | 203 * the current isolate is using. |
186 * | 204 * |
187 * WARNING: The [packageRoot] parameter is not implemented on all | 205 * WARNING: The [packageRoot] parameter is not implemented on all |
188 * platforms yet. | 206 * platforms yet. |
189 * | 207 * |
190 * If the [paused] parameter is set to `true`, | |
191 * the isolate will start up in a paused state, | |
192 * as if by an initial call of `isolate.pause(isolate.pauseCapability)`. | |
193 * This allows setting up error or exit listeners on the isolate | |
194 * before it starts running. | |
195 * To resume the isolate, call `isolate.resume(isolate.pauseCapability)`. | |
196 * | |
197 * WARNING: The `pause` parameter is not implemented on all platforms yet. | |
198 * | |
199 * Returns a future that will complete with an [Isolate] instance if the | 208 * Returns a future that will complete with an [Isolate] instance if the |
200 * spawning succeeded. It will complete with an error otherwise. | 209 * spawning succeeded. It will complete with an error otherwise. |
201 */ | 210 */ |
202 external static Future<Isolate> spawnUri( | 211 external static Future<Isolate> spawnUri( |
203 Uri uri, | 212 Uri uri, |
204 List<String> args, | 213 List<String> args, |
205 var message, | 214 var message, |
206 {bool paused: false, | 215 {bool paused: false, |
| 216 bool checked, |
207 Uri packageRoot}); | 217 Uri packageRoot}); |
208 | 218 |
209 /** | 219 /** |
210 * Requests the isolate to pause. | 220 * Requests the isolate to pause. |
211 * | 221 * |
212 * The isolate should stop handling events by pausing its event queue. | 222 * The isolate should stop handling events by pausing its event queue. |
213 * The request will eventually make the isolate stop doing anything. | 223 * The request will eventually make the isolate stop doing anything. |
214 * It will be handled before any other messages that are later sent to the | 224 * It will be handled before any other messages that are later sent to the |
215 * isolate from the current isolate, but no other guarantees are provided. | 225 * isolate from the current isolate, but no other guarantees are provided. |
216 * | 226 * |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 * as the original error, but has no other features of the original error. | 590 * as the original error, but has no other features of the original error. |
581 */ | 591 */ |
582 class RemoteError implements Error { | 592 class RemoteError implements Error { |
583 final String _description; | 593 final String _description; |
584 final StackTrace stackTrace; | 594 final StackTrace stackTrace; |
585 RemoteError(String description, String stackDescription) | 595 RemoteError(String description, String stackDescription) |
586 : _description = description, | 596 : _description = description, |
587 stackTrace = new StackTrace.fromString(stackDescription); | 597 stackTrace = new StackTrace.fromString(stackDescription); |
588 String toString() => _description; | 598 String toString() => _description; |
589 } | 599 } |
OLD | NEW |