Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: sdk/lib/isolate/isolate.dart

Issue 1181043003: be more explicit about when and how to register for listeners with isolates (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 * thing before it terminates. It will run no further code after the message 269 * thing before it terminates. It will run no further code after the message
270 * has been sent. 270 * has been sent.
271 * 271 *
272 * Adding the same port more than once will only cause it to receive one 272 * Adding the same port more than once will only cause it to receive one
273 * message, using the last response value that was added. 273 * message, using the last response value that was added.
274 * 274 *
275 * If the isolate is already dead, no message will be sent. 275 * If the isolate is already dead, no message will be sent.
276 * If `response` cannot be sent to the isolate, then the request is ignored. 276 * If `response` cannot be sent to the isolate, then the request is ignored.
277 * It is recommended to only use simple values that can be sent to all 277 * It is recommended to only use simple values that can be sent to all
278 * isolates, like `null`, booleans, numbers or strings. 278 * isolates, like `null`, booleans, numbers or strings.
279 *
280 * Since isolates run concurrently, it's possible for it to exit before the
281 * exit listener is established. To avoid this, start the isolate paused,
282 * add the listener, then resume it.
279 */ 283 */
280 /* TODO(lrn): Can we do better? Can the system recognize this message and 284 /* TODO(lrn): Can we do better? Can the system recognize this message and
281 * send a reply if the receiving isolate is dead? 285 * send a reply if the receiving isolate is dead?
282 */ 286 */
283 external void addOnExitListener(SendPort responsePort, {Object response}); 287 external void addOnExitListener(SendPort responsePort, {Object response});
284 288
285 /** 289 /**
286 * Stop listening on exit messages from the isolate. 290 * Stop listening on exit messages from the isolate.
287 * 291 *
288 * If a call has previously been made to [addOnExitListener] with the same 292 * If a call has previously been made to [addOnExitListener] with the same
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 * 361 *
358 * The errors are sent back as two elements lists. 362 * The errors are sent back as two elements lists.
359 * The first element is a `String` representation of the error, usually 363 * The first element is a `String` representation of the error, usually
360 * created by calling `toString` on the error. 364 * created by calling `toString` on the error.
361 * The second element is a `String` representation of an accompanying 365 * The second element is a `String` representation of an accompanying
362 * stack trace, or `null` if no stack trace was provided. 366 * stack trace, or `null` if no stack trace was provided.
363 * To convert this back to a [StackTrace] object, use [StackTrace.fromString]. 367 * To convert this back to a [StackTrace] object, use [StackTrace.fromString].
364 * 368 *
365 * Listening using the same port more than once does nothing. It will only 369 * Listening using the same port more than once does nothing. It will only
366 * get each error once. 370 * get each error once.
371 *
372 * Since isolates run concurrently, it's possible for it to exit before the
nweiz 2015/06/12 19:18:55 "exit" -> "emit an error"
Lasse Reichstein Nielsen 2015/06/12 19:38:16 "exit or emit an error"? It can do either or both
nweiz 2015/06/12 21:05:43 That's true, but if it exits before the listener i
373 * error listener is established. To avoid this, start the isolate paused,
374 * add the listener, then resume it.
367 */ 375 */
368 external void addErrorListener(SendPort port); 376 external void addErrorListener(SendPort port);
369 377
370 /** 378 /**
371 * Stop listening for uncaught errors through [port]. 379 * Stop listening for uncaught errors through [port].
372 * 380 *
373 * The `port` should be a port that is listening for errors through 381 * The `port` should be a port that is listening for errors through
374 * [addErrorListener]. This call requests that the isolate stops sending 382 * [addErrorListener]. This call requests that the isolate stops sending
375 * errors on the port. 383 * errors on the port.
376 * 384 *
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 * as the original error, but has no other features of the original error. 598 * as the original error, but has no other features of the original error.
591 */ 599 */
592 class RemoteError implements Error { 600 class RemoteError implements Error {
593 final String _description; 601 final String _description;
594 final StackTrace stackTrace; 602 final StackTrace stackTrace;
595 RemoteError(String description, String stackDescription) 603 RemoteError(String description, String stackDescription)
596 : _description = description, 604 : _description = description,
597 stackTrace = new StackTrace.fromString(stackDescription); 605 stackTrace = new StackTrace.fromString(stackDescription);
598 String toString() => _description; 606 String toString() => _description;
599 } 607 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698