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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 * Closes `this`. | 171 * Closes `this`. |
172 * | 172 * |
173 * If the stream has not been canceled yet, adds a close-event to the event | 173 * If the stream has not been canceled yet, adds a close-event to the event |
174 * queue and discards any further incoming messages. | 174 * queue and discards any further incoming messages. |
175 * | 175 * |
176 * If the stream has already been canceled this method has no effect. | 176 * If the stream has already been canceled this method has no effect. |
177 */ | 177 */ |
178 void close(); | 178 void close(); |
179 | 179 |
180 /** | 180 /** |
181 * Returns a send port that sends to this receive port. | 181 * Returns a [SendPort] that sends to this receive port. |
182 */ | 182 */ |
183 SendPort get sendPort; | 183 SendPort get sendPort; |
184 } | 184 } |
185 | 185 |
186 abstract class RawReceivePort { | 186 abstract class RawReceivePort { |
187 /** | 187 /** |
188 * Opens a long-lived port for receiving messages. | 188 * Opens a long-lived port for receiving messages. |
189 * | 189 * |
190 * A [RawReceivePort] is low level and does not work with [Zone]s. It | 190 * A [RawReceivePort] is low level and does not work with [Zone]s. It |
191 * can not be paused. The data-handler must be set before the first | 191 * can not be paused. The data-handler must be set before the first |
192 * event is received. | 192 * event is received. |
193 */ | 193 */ |
194 external factory RawReceivePort([void handler(event)]); | 194 external factory RawReceivePort([void handler(event)]); |
195 | 195 |
196 /** | 196 /** |
197 * Sets the handler that is invoked for every incoming message. | 197 * Sets the handler that is invoked for every incoming message. |
198 * | 198 * |
199 * The handler is invoked in the root-zone ([Zone.ROOT]). | 199 * The handler is invoked in the root-zone ([Zone.ROOT]). |
200 */ | 200 */ |
201 void set handler(Function newHandler); | 201 void set handler(Function newHandler); |
202 | 202 |
203 /** | 203 /** |
204 * Closes the port. | 204 * Closes the port. |
205 * | 205 * |
206 * After a call to this method any incoming message is silently dropped. | 206 * After a call to this method any incoming message is silently dropped. |
207 */ | 207 */ |
208 void close(); | 208 void close(); |
| 209 |
| 210 /** |
| 211 * Returns a [SendPort] that sends to this receive port. |
| 212 */ |
| 213 SendPort get sendPort; |
209 } | 214 } |
210 | 215 |
211 /** | 216 /** |
212 * Wraps unhandled exceptions thrown during isolate execution. It is | 217 * Wraps unhandled exceptions thrown during isolate execution. It is |
213 * used to show both the error message and the stack trace for unhandled | 218 * used to show both the error message and the stack trace for unhandled |
214 * exceptions. | 219 * exceptions. |
215 */ | 220 */ |
216 // TODO(floitsch): probably going to remove and replace with something else. | 221 // TODO(floitsch): probably going to remove and replace with something else. |
217 class _IsolateUnhandledException implements Exception { | 222 class _IsolateUnhandledException implements Exception { |
218 /** Message being handled when exception occurred. */ | 223 /** Message being handled when exception occurred. */ |
219 final message; | 224 final message; |
220 | 225 |
221 /** Wrapped exception. */ | 226 /** Wrapped exception. */ |
222 final source; | 227 final source; |
223 | 228 |
224 /** Trace for the wrapped exception. */ | 229 /** Trace for the wrapped exception. */ |
225 final StackTrace stackTrace; | 230 final StackTrace stackTrace; |
226 | 231 |
227 const _IsolateUnhandledException(this.message, this.source, this.stackTrace); | 232 const _IsolateUnhandledException(this.message, this.source, this.stackTrace); |
228 | 233 |
229 String toString() { | 234 String toString() { |
230 return 'IsolateUnhandledException: exception while handling message: ' | 235 return 'IsolateUnhandledException: exception while handling message: ' |
231 '${message} \n ' | 236 '${message} \n ' |
232 '${source.toString().replaceAll("\n", "\n ")}\n' | 237 '${source.toString().replaceAll("\n", "\n ")}\n' |
233 'original stack trace:\n ' | 238 'original stack trace:\n ' |
234 '${stackTrace.toString().replaceAll("\n","\n ")}'; | 239 '${stackTrace.toString().replaceAll("\n","\n ")}'; |
235 } | 240 } |
236 } | 241 } |
OLD | NEW |