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

Unified Diff: sdk/lib/_internal/compiler/js_lib/isolate_helper.dart

Issue 1074223002: Update Isolate API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo Created 5 years, 8 months 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
« no previous file with comments | « runtime/vm/isolate.cc ('k') | sdk/lib/_internal/compiler/js_lib/isolate_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/js_lib/isolate_helper.dart
diff --git a/sdk/lib/_internal/compiler/js_lib/isolate_helper.dart b/sdk/lib/_internal/compiler/js_lib/isolate_helper.dart
index 9d36be556b0a7ccc5a975e2c32ba2908ade7862a..6f3e3611ded95104da05c24ec0659f54c6b6021f 100644
--- a/sdk/lib/_internal/compiler/js_lib/isolate_helper.dart
+++ b/sdk/lib/_internal/compiler/js_lib/isolate_helper.dart
@@ -311,7 +311,7 @@ class _IsolateContext implements IsolateContext {
List<_IsolateEvent> delayedEvents = [];
Set<Capability> pauseTokens = new Set();
- // Container with the "on exit" handler send-ports.
+ // Container with the "on exit" handler send-ports and responses.
var doneHandlers;
/**
@@ -355,14 +355,12 @@ class _IsolateContext implements IsolateContext {
_updateGlobalState();
}
- void addDoneListener(SendPort responsePort) {
+ void addDoneListener(SendPort responsePort, Object response) {
if (doneHandlers == null) {
- doneHandlers = [];
+ // TODO(lrn): Use map optimized for few keys.
+ doneHandlers = new HashMap();
}
- // If necessary, we can switch doneHandlers to a Set if it gets larger.
- // That is not expected to happen in practice.
- if (doneHandlers.contains(responsePort)) return;
- doneHandlers.add(responsePort);
+ doneHandlers[responsePort] = response;
}
void removeDoneListener(SendPort responsePort) {
@@ -375,18 +373,14 @@ class _IsolateContext implements IsolateContext {
this.errorsAreFatal = errorsAreFatal;
}
- void handlePing(SendPort responsePort, int pingType) {
+ void handlePing(SendPort responsePort, int pingType, Object response) {
if (pingType == Isolate.IMMEDIATE ||
(pingType == Isolate.BEFORE_NEXT_EVENT &&
!_isExecutingEvent)) {
- responsePort.send(null);
- return;
- }
- void respond() { responsePort.send(null); }
- if (pingType == Isolate.AS_EVENT) {
- _globalState.topEventLoop.enqueue(this, respond, "ping");
+ responsePort.send(response);
return;
}
+ void respond() { responsePort.send(response); }
assert(pingType == Isolate.BEFORE_NEXT_EVENT);
if (_scheduledControlEvents == null) {
_scheduledControlEvents = new Queue();
@@ -402,10 +396,6 @@ class _IsolateContext implements IsolateContext {
kill();
return;
}
- if (priority == Isolate.AS_EVENT) {
- _globalState.topEventLoop.enqueue(this, kill, "kill");
- return;
- }
assert(priority == Isolate.BEFORE_NEXT_EVENT);
if (_scheduledControlEvents == null) {
_scheduledControlEvents = new Queue();
@@ -499,7 +489,7 @@ class _IsolateContext implements IsolateContext {
removePause(message[1]);
break;
case 'add-ondone':
- addDoneListener(message[1]);
+ addDoneListener(message[1], message[2]);
break;
case 'remove-ondone':
removeDoneListener(message[1]);
@@ -508,7 +498,7 @@ class _IsolateContext implements IsolateContext {
setErrorsFatal(message[1], message[2]);
break;
case "ping":
- handlePing(message[1], message[2]);
+ handlePing(message[1], message[2], message[3]);
break;
case "kill":
handleKill(message[1], message[2]);
@@ -574,9 +564,7 @@ class _IsolateContext implements IsolateContext {
_globalState.isolates.remove(id); // indicate this isolate is not active
errorPorts.clear();
if (doneHandlers != null) {
- for (SendPort port in doneHandlers) {
- port.send(null);
- }
+ doneHandlers.forEach((port, response) { port.send(response); });
doneHandlers = null;
}
}
« no previous file with comments | « runtime/vm/isolate.cc ('k') | sdk/lib/_internal/compiler/js_lib/isolate_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698