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..cee2023260aeffd0809b3db21ee1bcef4e115731 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. |
| * |
| @@ -133,6 +140,37 @@ class Isolate { |
| ..[1] = resumeCapability; |
| controlPort.send(message); |
| } |
| + |
| + /** |
|
Søren Gjesse
2014/03/04 10:20:35
Add WARNING.
Lasse Reichstein Nielsen
2014/03/04 12:03:32
Done.
|
| + * 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. |
| + * The response should happen no sooner than if sent with `PING_CONTROL`. |
|
floitsch
2014/03/04 12:12:51
no later?
Lasse Reichstein Nielsen
2014/03/06 12:47:17
Done.
|
| + * It may be sent earlier of the system has a way to do so. |
|
floitsch
2014/03/04 12:12:51
if the system
Lasse Reichstein Nielsen
2014/03/06 12:47:17
Done.
|
| + * * `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. |
| + */ |
| + void ping(SendPort responsePort, [int pingType = PING_ALIVE]) { |
|
Søren Gjesse
2014/03/04 10:20:35
No capability needed for this?
Lasse Reichstein Nielsen
2014/03/04 12:03:32
No. You don't affect how the isolate runs and don'
floitsch
2014/03/04 12:12:51
I think that ping is the minimal thing we can do.
|
| + var message = new List(3) |
| + ..[0] = "ping" |
| + ..[1] = responsePort |
| + ..[2] = pingType; |
| + controlPort.send(message); |
| + } |
| } |
| /** |