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

Unified Diff: sdk/lib/isolate/isolate.dart

Issue 2062683002: Address shortcomings in documentation on Isolate class. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/isolate/isolate.dart
diff --git a/sdk/lib/isolate/isolate.dart b/sdk/lib/isolate/isolate.dart
index 8caccdb4e0ac56198ceae436b91e2e68350d3211..cb09da7c8b0e7b3e620e36631752ac3c008477b0 100644
--- a/sdk/lib/isolate/isolate.dart
+++ b/sdk/lib/isolate/isolate.dart
@@ -7,9 +7,9 @@
* independent workers that are similar to threads
* but don't share memory,
* communicating only via messages.
- *
+ *
* To use this library in your code:
- *
+ *
* import 'dart:isolate';
*/
library dart.isolate;
@@ -162,19 +162,27 @@ class Isolate {
* Creates and spawns an isolate that shares the same code as the current
* isolate.
*
- * The argument [entryPoint] specifies the entry point of the spawned
- * isolate. It must be a top-level function or a static method that
- * takes one argument - that is, one-parameter functions that can be
- * compile-time constant function values.
- * It is not allowed to pass the value of function expressions or an instance
- * method extracted from an object.
+ * The argument [entryPoint] specifies the initial function to call
+ * in the spawned isolate.
+ * The entry-point function is invoked in the new isolate with [message]
+ * as the only argument.
+ *
+ * The function must be a top-level function or a static method
+ * that can be called with a single argument -
eernst 2016/06/14 11:36:47 Might as well use ',' because the single hyphen is
Lasse Reichstein Nielsen 2016/07/04 11:47:32 Done.
+ * that is, a compile-time constant function value
+ * which accepts at least one positional parameter
+ * and has at most one required positional parameter.
+ * The function may accept any number of optional parameters,
+ * as long as they *can* be called with just a single argument.
eernst 2016/06/14 11:36:47 There's a singular/plural issue here, and I also t
Lasse Reichstein Nielsen 2016/07/04 11:47:33 Done.
+ * The value of a function expressions or a torn-off instance methods are not
+ * allowed.
eernst 2016/06/14 11:36:47 A bit of confusion here, too. Maybe it would work
Lasse Reichstein Nielsen 2016/07/04 11:47:33 You can't pass an expression, only its value. Rewo
*
- * The entry-point function is invoked with the initial [message].
* Usually the initial [message] contains a [SendPort] so
* that the spawner and spawnee can communicate with each other.
*
* If the [paused] parameter is set to `true`,
* the isolate will start up in a paused state,
+ * just before calling the [entryPoint] function with the [message],
* as if by an initial call of `isolate.pause(isolate.pauseCapability)`.
* To resume the isolate, call `isolate.resume(isolate.pauseCapability)`.
*
@@ -184,19 +192,22 @@ class Isolate {
* corresponding parameter and was processed before the isolate starts
* running.
*
+ * If [errorsAreFatal] is omitted, the platform may choose a default behavior
+ * or inherit the current isolate's behavior.
+ *
* You can also call the [setErrorsFatal], [addOnExitListener] and
* [addErrorListener] methods on the returned isolate, but unless the
* isolate was started as [paused], it may already have terminated
* before those methods can complete.
*
- * Returns a future that will complete with an [Isolate] instance if the
+ * Returns a future which will complete with an [Isolate] instance if the
* spawning succeeded. It will complete with an error otherwise.
*/
external static Future<Isolate> spawn(void entryPoint(message), var message,
- { bool paused: false,
- bool errorsAreFatal,
- SendPort onExit,
- SendPort onError });
+ {bool paused: false,
+ bool errorsAreFatal,
+ SendPort onExit,
+ SendPort onError});
/**
* Creates and spawns an isolate that runs the code from the library with
@@ -291,13 +302,16 @@ class Isolate {
/**
* Requests the isolate to pause.
*
- * The isolate should stop handling events by pausing its event queue.
- * The request will eventually make the isolate stop doing anything.
- * It will be handled before any other messages that are later sent to the
- * isolate from the current isolate, but no other guarantees are provided.
+ * When the isolate receives the pause command, it will stop
floitsch 2016/06/16 08:36:34 Stops
Lasse Reichstein Nielsen 2016/07/04 11:47:33 Done.
+ * processing events from the event loop queue.
+ * It may still add new events to the queue in response to, e.g., timers
+ * or receive port messages. When the isolate is resumed, it will handle
floitsch 2016/06/16 08:36:35 Maybe "handles" but here it really is in the futur
Lasse Reichstein Nielsen 2016/07/04 11:47:32 Used "handles" and improved the second half of the
+ * the enqueued events in the order they were enqueued.
*
- * The event loop may be paused before previously sent, but not yet exeuted,
- * messages have been reached.
+ * The pause request is sent through the isolate's command port and will be
+ * handled when it is received, after other previously sent command messages,
+ * but before already enqueued event loop events that hasn't been processed
eernst 2016/06/14 11:36:47 'after any previously sent command messages, but b
Lasse Reichstein Nielsen 2016/07/04 11:47:32 Event loop events are enqueued until they are proc
+ * yet.
*
* If [resumeCapability] is provided, it is used to identity the pause,
* and must be used again to end the pause using [resume].
« 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