Index: sdk/lib/isolate/isolate.dart |
diff --git a/sdk/lib/isolate/isolate.dart b/sdk/lib/isolate/isolate.dart |
index a8063a083e695b133935d081f440d7010259e43f..71a51c9355292a49070150daa025240c726c9acf 100644 |
--- a/sdk/lib/isolate/isolate.dart |
+++ b/sdk/lib/isolate/isolate.dart |
@@ -36,9 +36,20 @@ class Isolate { |
* to the control port. |
*/ |
final SendPort controlPort; |
+ /** |
+ * Capability granting the ability to pause the isolate. |
+ */ |
final Capability pauseCapability; |
+ /** |
+ * Capability granting the ability to inspect the isolate. |
+ * |
+ * This capability is needed to be able to see uncaught errors and exit of |
+ * the isolate. |
floitsch
2014/02/25 19:25:48
I don't think inspecting is the same as being able
Lasse Reichstein Nielsen
2014/02/27 08:04:28
Would "observe" be a better word. It suggests a mo
|
+ */ |
+ final Capability inspectCapability; |
- Isolate._fromControlPort(this.controlPort, [this.pauseCapability]); |
+ Isolate._fromControlPort(this.controlPort, [this.pauseCapability, |
+ this.inspectCapability]); |
/** |
* Creates and spawns an isolate that shares the same code as the current |
@@ -96,7 +107,7 @@ class Isolate { |
* and must be used again to end the pause using [resume]. |
* Otherwise a new capability is created and returned. |
* |
- * If an isolate is paused more than once using the same capabilty, |
+ * If an isolate is paused more than once using the same capability, |
* only one resume with that capability is needed to end the pause. |
* |
* If an isolate is paused using more than one capability, |
@@ -133,6 +144,26 @@ class Isolate { |
..[1] = resumeCapability; |
controlPort.send(message); |
} |
+ |
+ /** |
+ * Returns a future that completes after the isolate has terminated. |
+ */ |
+ Future get onExit { |
+ // Should we return a broadcast stream instead? It has the advantage |
floitsch
2014/02/25 19:25:48
I don't see any stream.
Lasse Reichstein Nielsen
2014/02/27 08:04:28
No, I was suggesting a broadcast stream instead of
|
+ // that you can stop listening again. |
+ var completer = new Completer(); |
+ var receivePort; |
+ receivePort = new RawReceivePort((_) { |
+ completer.complete(); |
+ receivePort.close(); |
+ }); |
+ var message = new List(3) |
+ ..[0] = "ondone" |
+ ..[1] = inspectCapability |
+ ..[2] = receivePort.sendPort; |
+ controlPort.send(message); |
+ return completer.future; |
+ } |
} |
/** |