Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Unified Diff: runtime/lib/isolate.dart

Issue 8588040: Add a mid-sized integration test for the Dart Embedding Api which (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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++;
_onMessage = onMessage;
}
close() {
_portMap.remove(_id);
_closeInternal(_id);
+ _numLivePorts--;
}
SendPort toSendPort() {
@@ -32,18 +34,23 @@
/**** 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() {
Anton Muhin 2011/11/23 19:28:14 nit: I'd write static int _getNumLivePorts() => _
turnidge 2011/11/23 21:45:37 Done.
+ return (_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 +65,9 @@
// id to ReceivePort mapping.
static Map _portMap;
+
+ // The number of ReceivePorts which have called receive.
+ static int _numLivePorts;
}
@@ -119,9 +129,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);
}

Powered by Google App Engine
This is Rietveld 408576698