| Index: sdk/lib/isolate/isolate.dart
|
| diff --git a/sdk/lib/isolate/isolate.dart b/sdk/lib/isolate/isolate.dart
|
| index 47b57f969acb7189ffff618a5cccbb5d27b9db0e..3ae06e9b7c75ec0b9a055d4cfbe23f785ba2d996 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.
|
| *
|
| @@ -223,6 +230,39 @@ class Isolate {
|
| ..[2] = errorsAreFatal;
|
| controlPort.send(message);
|
| }
|
| +
|
| + /**
|
| + * Request that the isolate send a response on the [responsePort].
|
| + *
|
| + * WARNING: This method is experimental and not handled on every platform yet.
|
| + *
|
| + * 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 later than if sent with `PING_CONTROL`.
|
| + * It may be sent earlier if the system has a way to do so.
|
| + * * `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]) {
|
| + var message = new List(3)
|
| + ..[0] = "ping"
|
| + ..[1] = responsePort
|
| + ..[2] = pingType;
|
| + controlPort.send(message);
|
| + }
|
| }
|
|
|
| /**
|
|
|