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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 * | 200 * |
201 * Usually the initial [message] contains a [SendPort] so | 201 * Usually the initial [message] contains a [SendPort] so |
202 * that the spawner and spawnee can communicate with each other. | 202 * that the spawner and spawnee can communicate with each other. |
203 * | 203 * |
204 * If the [paused] parameter is set to `true`, | 204 * If the [paused] parameter is set to `true`, |
205 * the isolate will start up in a paused state, | 205 * the isolate will start up in a paused state, |
206 * just before calling the [entryPoint] function with the [message], | 206 * just before calling the [entryPoint] function with the [message], |
207 * as if by an initial call of `isolate.pause(isolate.pauseCapability)`. | 207 * as if by an initial call of `isolate.pause(isolate.pauseCapability)`. |
208 * To resume the isolate, call `isolate.resume(isolate.pauseCapability)`. | 208 * To resume the isolate, call `isolate.resume(isolate.pauseCapability)`. |
209 * | 209 * |
210 * If the [errorAreFatal], [onExit] and/or [onError] parameters are provided, | 210 * If the [errorsAreFatal], [onExit] and/or [onError] parameters are provided, |
211 * the isolate will act as if, respectively, [setErrorsFatal], | 211 * the isolate will act as if, respectively, [setErrorsFatal], |
212 * [addOnExitListener] and [addErrorListener] were called with the | 212 * [addOnExitListener] and [addErrorListener] were called with the |
213 * corresponding parameter and was processed before the isolate starts | 213 * corresponding parameter and was processed before the isolate starts |
214 * running. | 214 * running. |
215 * | 215 * |
216 * If [errorsAreFatal] is omitted, the platform may choose a default behavior | 216 * If [errorsAreFatal] is omitted, the platform may choose a default behavior |
217 * or inherit the current isolate's behavior. | 217 * or inherit the current isolate's behavior. |
218 * | 218 * |
219 * You can also call the [setErrorsFatal], [addOnExitListener] and | 219 * You can also call the [setErrorsFatal], [addOnExitListener] and |
220 * [addErrorListener] methods on the returned isolate, but unless the | 220 * [addErrorListener] methods on the returned isolate, but unless the |
(...skipping 24 matching lines...) Expand all Loading... |
245 * * `main(args, message)` | 245 * * `main(args, message)` |
246 * | 246 * |
247 * When present, the parameter `args` is set to the provided [args] list. | 247 * When present, the parameter `args` is set to the provided [args] list. |
248 * When present, the parameter `message` is set to the initial [message]. | 248 * When present, the parameter `message` is set to the initial [message]. |
249 * | 249 * |
250 * If the [paused] parameter is set to `true`, | 250 * If the [paused] parameter is set to `true`, |
251 * the isolate will start up in a paused state, | 251 * the isolate will start up in a paused state, |
252 * as if by an initial call of `isolate.pause(isolate.pauseCapability)`. | 252 * as if by an initial call of `isolate.pause(isolate.pauseCapability)`. |
253 * To resume the isolate, call `isolate.resume(isolate.pauseCapability)`. | 253 * To resume the isolate, call `isolate.resume(isolate.pauseCapability)`. |
254 * | 254 * |
255 * If the [errorAreFatal], [onExit] and/or [onError] parameters are provided, | 255 * If the [errorsAreFatal], [onExit] and/or [onError] parameters are provided, |
256 * the isolate will act as if, respectively, [setErrorsFatal], | 256 * the isolate will act as if, respectively, [setErrorsFatal], |
257 * [addOnExitListener] and [addErrorListener] were called with the | 257 * [addOnExitListener] and [addErrorListener] were called with the |
258 * corresponding parameter and was processed before the isolate starts | 258 * corresponding parameter and was processed before the isolate starts |
259 * running. | 259 * running. |
260 * | 260 * |
261 * You can also call the [setErrorsFatal], [addOnExitListener] and | 261 * You can also call the [setErrorsFatal], [addOnExitListener] and |
262 * [addErrorListener] methods on the returned isolate, but unless the | 262 * [addErrorListener] methods on the returned isolate, but unless the |
263 * isolate was started as [paused], it may already have terminated | 263 * isolate was started as [paused], it may already have terminated |
264 * before those methods can complete. | 264 * before those methods can complete. |
265 * | 265 * |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 /** | 409 /** |
410 * Stops listening for exit messages from the isolate. | 410 * Stops listening for exit messages from the isolate. |
411 * | 411 * |
412 * Requests for the isolate to not send exit messages on [responsePort]. | 412 * Requests for the isolate to not send exit messages on [responsePort]. |
413 * If the isolate isn't expecting to send exit messages on [responsePort], | 413 * If the isolate isn't expecting to send exit messages on [responsePort], |
414 * because the port hasn't been added using [addOnExitListener], | 414 * because the port hasn't been added using [addOnExitListener], |
415 * or because it has already been removed, the request is ignored. | 415 * or because it has already been removed, the request is ignored. |
416 * | 416 * |
417 * If the same port has been passed via [addOnExitListener] more than once, | 417 * If the same port has been passed via [addOnExitListener] more than once, |
418 * only one call to `removeOnExitListener` is needed to stop it from receiving | 418 * only one call to `removeOnExitListener` is needed to stop it from receiving |
419 * exit messagees. | 419 * exit messages. |
420 * | 420 * |
421 * Closing the receive port that is associated with the [responsePort] does | 421 * Closing the receive port that is associated with the [responsePort] does |
422 * not stop the isolate from sending uncaught errors, they are just going to | 422 * not stop the isolate from sending uncaught errors, they are just going to |
423 * be lost. | 423 * be lost. |
424 * | 424 * |
425 * An exit message may still be sent if the isolate terminates | 425 * An exit message may still be sent if the isolate terminates |
426 * before this request is received and processed. | 426 * before this request is received and processed. |
427 */ | 427 */ |
428 external void removeOnExitListener(SendPort responsePort); | 428 external void removeOnExitListener(SendPort responsePort); |
429 | 429 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 /** | 526 /** |
527 * Stops listening for uncaught errors from the isolate. | 527 * Stops listening for uncaught errors from the isolate. |
528 * | 528 * |
529 * Requests for the isolate to not send uncaught errors on [port]. | 529 * Requests for the isolate to not send uncaught errors on [port]. |
530 * If the isolate isn't expecting to send uncaught errors on [port], | 530 * If the isolate isn't expecting to send uncaught errors on [port], |
531 * because the port hasn't been added using [addErrorListener], | 531 * because the port hasn't been added using [addErrorListener], |
532 * or because it has already been removed, the request is ignored. | 532 * or because it has already been removed, the request is ignored. |
533 * | 533 * |
534 * If the same port has been passed via [addErrorListener] more than once, | 534 * If the same port has been passed via [addErrorListener] more than once, |
535 * only one call to `removeErrorListener` is needed to stop it from receiving | 535 * only one call to `removeErrorListener` is needed to stop it from receiving |
536 * unaught errors. | 536 * uncaught errors. |
537 * | 537 * |
538 * Uncaught errors message may still be sent by the isolate | 538 * Uncaught errors message may still be sent by the isolate |
539 * until this request is received and processed. | 539 * until this request is received and processed. |
540 */ | 540 */ |
541 external void removeErrorListener(SendPort port); | 541 external void removeErrorListener(SendPort port); |
542 | 542 |
543 /** | 543 /** |
544 * Returns a broadcast stream of uncaught errors from the isolate. | 544 * Returns a broadcast stream of uncaught errors from the isolate. |
545 * | 545 * |
546 * Each error is provided as an error event on the stream. | 546 * Each error is provided as an error event on the stream. |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 * as the original error, but has no other features of the original error. | 721 * as the original error, but has no other features of the original error. |
722 */ | 722 */ |
723 class RemoteError implements Error { | 723 class RemoteError implements Error { |
724 final String _description; | 724 final String _description; |
725 final StackTrace stackTrace; | 725 final StackTrace stackTrace; |
726 RemoteError(String description, String stackDescription) | 726 RemoteError(String description, String stackDescription) |
727 : _description = description, | 727 : _description = description, |
728 stackTrace = new StackTrace.fromString(stackDescription); | 728 stackTrace = new StackTrace.fromString(stackDescription); |
729 String toString() => _description; | 729 String toString() => _description; |
730 } | 730 } |
OLD | NEW |