| 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 12 matching lines...) Expand all Loading... |
| 23 // TODO(floitsch): clean up spawn exception. | 23 // TODO(floitsch): clean up spawn exception. |
| 24 const IsolateSpawnException(String this._s); | 24 const IsolateSpawnException(String this._s); |
| 25 String toString() => "IsolateSpawnException: '$_s'"; | 25 String toString() => "IsolateSpawnException: '$_s'"; |
| 26 final String _s; | 26 final String _s; |
| 27 } | 27 } |
| 28 | 28 |
| 29 class Isolate { | 29 class Isolate { |
| 30 | 30 |
| 31 final SendPort _controlPort; | 31 final SendPort _controlPort; |
| 32 | 32 |
| 33 Isolate._fromControlPort(this._controlPort); | 33 Isolate.fromControlPort(SendPort controlPort) |
| 34 : this._controlPort = controlPort; |
| 34 | 35 |
| 35 /** | 36 /** |
| 36 * Creates and spawns an isolate that shares the same code as the current | 37 * Creates and spawns an isolate that shares the same code as the current |
| 37 * isolate. | 38 * isolate. |
| 38 * | 39 * |
| 39 * The argument [entryPoint] specifies the entry point of the spawned | 40 * The argument [entryPoint] specifies the entry point of the spawned |
| 40 * isolate. It must be a static top-level function or a static method that | 41 * isolate. It must be a static top-level function or a static method that |
| 41 * takes no arguments. It is not allowed to pass a function closure. | 42 * takes no arguments. It is not allowed to pass a function closure. |
| 42 * | 43 * |
| 43 * The entry-point function is invoked with the initial [message]. | 44 * The entry-point function is invoked with the initial [message]. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 * The content of [message] can be: primitive values (null, num, bool, double, | 92 * The content of [message] can be: primitive values (null, num, bool, double, |
| 92 * String), instances of [SendPort], and lists and maps whose elements are any | 93 * String), instances of [SendPort], and lists and maps whose elements are any |
| 93 * of these. List and maps are also allowed to be cyclic. | 94 * of these. List and maps are also allowed to be cyclic. |
| 94 * | 95 * |
| 95 * In the special circumstances when two isolates share the same code and are | 96 * In the special circumstances when two isolates share the same code and are |
| 96 * running in the same process (e.g. isolates created via [spawnFunction]), it | 97 * running in the same process (e.g. isolates created via [spawnFunction]), it |
| 97 * is also possible to send object instances (which would be copied in the | 98 * is also possible to send object instances (which would be copied in the |
| 98 * process). This is currently only supported by the dartvm. For now, the | 99 * process). This is currently only supported by the dartvm. For now, the |
| 99 * dart2js compiler only supports the restricted messages described above. | 100 * dart2js compiler only supports the restricted messages described above. |
| 100 * | 101 * |
| 101 * The second argument [replyTo] is deprecated. | 102 * The second argument [replyTo] is deprecated and its value is ignored. |
| 102 */ | 103 */ |
| 103 void send(var message, [SendPort replyTo]); | 104 void send(var message, [SendPort replyTo]); |
| 104 | 105 |
| 105 /** | 106 /** |
| 106 * Tests whether [other] is a [SendPort] pointing to the same | 107 * Tests whether [other] is a [SendPort] pointing to the same |
| 107 * [ReceivePort] as this one. | 108 * [ReceivePort] as this one. |
| 108 */ | 109 */ |
| 109 bool operator==(var other); | 110 bool operator==(var other); |
| 110 | 111 |
| 111 /** | 112 /** |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 const IsolateUnhandledException(this.message, this.source, this.stackTrace); | 232 const IsolateUnhandledException(this.message, this.source, this.stackTrace); |
| 232 | 233 |
| 233 String toString() { | 234 String toString() { |
| 234 return 'IsolateUnhandledException: exception while handling message: ' | 235 return 'IsolateUnhandledException: exception while handling message: ' |
| 235 '${message} \n ' | 236 '${message} \n ' |
| 236 '${source.toString().replaceAll("\n", "\n ")}\n' | 237 '${source.toString().replaceAll("\n", "\n ")}\n' |
| 237 'original stack trace:\n ' | 238 'original stack trace:\n ' |
| 238 '${stackTrace.toString().replaceAll("\n","\n ")}'; | 239 '${stackTrace.toString().replaceAll("\n","\n ")}'; |
| 239 } | 240 } |
| 240 } | 241 } |
| OLD | NEW |