Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 // TODO(floitsch): clean up spawn exception. | 24 // TODO(floitsch): clean up spawn exception. |
| 25 const IsolateSpawnException(String this._s); | 25 const IsolateSpawnException(String this._s); |
| 26 String toString() => "IsolateSpawnException: '$_s'"; | 26 String toString() => "IsolateSpawnException: '$_s'"; |
| 27 final String _s; | 27 final String _s; |
| 28 } | 28 } |
| 29 | 29 |
| 30 class Isolate { | 30 class Isolate { |
| 31 | 31 |
| 32 final SendPort _controlPort; | 32 final SendPort _controlPort; |
| 33 | 33 |
| 34 Isolate._fromControlPort(this._controlPort); | 34 Isolate._fromControlPort(SendPort controlPort) |
| 35 : this._controlPort = controlPort; | |
| 35 | 36 |
| 36 /** | 37 /** |
| 37 * Creates and spawns an isolate that shares the same code as the current | 38 * Creates and spawns an isolate that shares the same code as the current |
| 38 * isolate. | 39 * isolate. |
| 39 * | 40 * |
| 40 * The argument [entryPoint] specifies the entry point of the spawned | 41 * The argument [entryPoint] specifies the entry point of the spawned |
| 41 * isolate. It must be a static top-level function or a static method that | 42 * isolate. It must be a static top-level function or a static method that |
| 42 * takes no arguments. It is not allowed to pass a function closure. | 43 * takes no arguments. It is not allowed to pass a function closure. |
| 43 * | 44 * |
| 44 * The entry-point function is invoked with the initial [message]. | 45 * The entry-point function is invoked with the initial [message]. |
| (...skipping 46 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. |
|
Lasse Reichstein Nielsen
2013/10/25 12:45:59
Consider removing it now.
floitsch
2013/10/25 13:52:56
Can't.
| |
| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 const _IsolateUnhandledException(this.message, this.source, this.stackTrace); | 224 const _IsolateUnhandledException(this.message, this.source, this.stackTrace); |
| 224 | 225 |
| 225 String toString() { | 226 String toString() { |
| 226 return 'IsolateUnhandledException: exception while handling message: ' | 227 return 'IsolateUnhandledException: exception while handling message: ' |
| 227 '${message} \n ' | 228 '${message} \n ' |
| 228 '${source.toString().replaceAll("\n", "\n ")}\n' | 229 '${source.toString().replaceAll("\n", "\n ")}\n' |
| 229 'original stack trace:\n ' | 230 'original stack trace:\n ' |
| 230 '${stackTrace.toString().replaceAll("\n","\n ")}'; | 231 '${stackTrace.toString().replaceAll("\n","\n ")}'; |
| 231 } | 232 } |
| 232 } | 233 } |
| OLD | NEW |