Index: runtime/lib/isolate.dart |
=================================================================== |
--- runtime/lib/isolate.dart (revision 1762) |
+++ runtime/lib/isolate.dart (working copy) |
@@ -18,12 +18,14 @@ |
factory ReceivePortImpl() native "ReceivePortImpl_factory"; |
receive(void onMessage(var message, SendPort replyTo)) { |
+ _numLivePorts++; |
siva
2011/11/24 00:52:31
If I call receive multiple times on the same recei
turnidge
2011/11/29 01:01:31
I redid the change so that isolate.dart doesn't ne
|
_onMessage = onMessage; |
} |
close() { |
_portMap.remove(_id); |
_closeInternal(_id); |
+ _numLivePorts--; |
} |
SendPort toSendPort() { |
@@ -32,18 +34,21 @@ |
/**** Internal implementation details ****/ |
// Called from the VM to create a new ReceivePort instance. |
- static ReceivePortImpl create_(int id) { |
+ static ReceivePortImpl _create(int id) { |
return new ReceivePortImpl._internal(id); |
} |
ReceivePortImpl._internal(int id) : _id = id { |
if (_portMap === null) { |
_portMap = new Map(); |
+ _numLivePorts = 0; |
} |
_portMap[id] = this; |
} |
+ static int _getNumLivePorts() => _numLivePorts === null ? 0 : _numLivePorts; |
+ |
// Called from the VM to dispatch to the handler. |
- static void handleMessage_(int id, int replyId, var message) { |
+ static void _handleMessage(int id, int replyId, var message) { |
assert(_portMap !== null); |
ReceivePort port = _portMap[id]; |
SendPort replyTo = (replyId == 0) ? null : new SendPortImpl(replyId); |
@@ -58,6 +63,9 @@ |
// id to ReceivePort mapping. |
static Map _portMap; |
+ |
+ // The number of ReceivePorts which have called receive. |
+ static int _numLivePorts; |
} |
@@ -119,9 +127,9 @@ |
/*--- private implementation ---*/ |
const SendPortImpl(int id) : _id = id; |
- // SendPortImpl.create_ is called from the VM when a new SendPort instance is |
+ // SendPortImpl._create is called from the VM when a new SendPort instance is |
// needed by the VM code. |
- static SendPort create_(int id) { |
+ static SendPort _create(int id) { |
return new SendPortImpl(id); |
} |