Chromium Code Reviews| Index: sdk/lib/isolate/isolate.dart |
| diff --git a/sdk/lib/isolate/isolate.dart b/sdk/lib/isolate/isolate.dart |
| index a8063a083e695b133935d081f440d7010259e43f..0781697b5907039fd2ec036e29e3e59f921cf8f1 100644 |
| --- a/sdk/lib/isolate/isolate.dart |
| +++ b/sdk/lib/isolate/isolate.dart |
| @@ -29,6 +29,13 @@ class IsolateSpawnException implements Exception { |
| } |
| class Isolate { |
| + /** Argument to `ping`: Ask for immediate response. */ |
| + static const int PING_ALIVE = 0; |
| + /** Argument to `ping`: Ask for response after control events. */ |
| + static const int PING_CONTROL = 1; |
| + /** Argument to `ping`: Ask for response after normal events. */ |
| + static const int PING_EVENT = 2; |
| + |
| /** |
| * Control port used to send control messages to the isolate. |
| * |
| @@ -104,7 +111,7 @@ class Isolate { |
| * |
| * Returns the capability that must be used to resume end the pause. |
| * |
| - * WARNING: This method is not handled on any platform yet. |
| + * WARNING: This method is not handled on all platforms yet. |
| */ |
| Capability pause([Capability resumeCapability]) { |
| if (resumeCapability == null) resumeCapability = new Capability(); |
| @@ -125,7 +132,7 @@ class Isolate { |
| * The capability must be one returned by a call to [pause] on this |
| * isolate, otherwise the resume call does nothing. |
| * |
| - * WARNING: This method is not handled on any platform yet. |
| + * WARNING: This method is not handled on all platforms yet. |
| */ |
| void resume(Capability resumeCapability) { |
| var message = new List(2) |
| @@ -133,6 +140,39 @@ class Isolate { |
| ..[1] = resumeCapability; |
| controlPort.send(message); |
| } |
| + |
| + /** |
| + * Request that the isolate send a response on the [responsePort]. |
| + * |
| + * If the isolate is alive, it will eventually send a `null` response on |
| + * the response port. |
| + * |
| + * The [pingType] must be one of [PING_ALIVE], [PING_CONTROL] or [PING_EVENT]. |
| + * The response is sent at different times depending on the ping type: |
| + * |
| + * * `PING_ALIVE`: The the isolate responds as soon as possible. |
|
Anders Johnsen
2014/03/04 14:06:20
The the
|
| + * The response should happen no sooner than if sent with `PING_CONTROL`. |
| + * It may be sent earlier of the system has a way to do so. |
|
Anders Johnsen
2014/03/04 14:06:20
of -> if
|
| + * * `PING_CONTROL`: The response it not sent until all previously sent |
| + * control messages from the current isolate to the receiving isolate |
| + * have been processed. This can be used to wait for |
| + * previously sent control messages. |
| + * * `PING_EVENT`: The response is not sent until all prevously sent |
| + * non-control messages from the current isolate to the receiving isolate |
| + * have been processed. |
| + * The ping effectively puts the resonse into the normal event queue after |
| + * previously sent messages. |
| + * This can be used to wait for a another event to be processed. |
| + * |
| + * WARNING: This method is not handled on all platforms yet. |
| + */ |
| + void ping(SendPort responsePort, [int pingType = PING_ALIVE]) { |
| + var message = new List(3) |
| + ..[0] = "ping" |
| + ..[1] = responsePort |
| + ..[2] = pingType; |
| + controlPort.send(message); |
| + } |
| } |
| /** |