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

Side by Side Diff: samples/isolate_html/IsolateSample.dart

Issue 9652001: SendPort + ReceivePort changes: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/snapshot_test.dart ('k') | samples/leap/leap_leg.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * These are the messages we are going to send to the isolates 6 * These are the messages we are going to send to the isolates
7 * that we create. 7 * that we create.
8 */ 8 */
9 class MessageId { 9 class MessageId {
10 static final INIT = "init"; 10 static final INIT = "init";
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 for (Element element in document.queryAll(".sendButton")) { 64 for (Element element in document.queryAll(".sendButton")) {
65 element.on.click.add((Event e) { 65 element.on.click.add((Event e) {
66 replyElement.text = "waiting for reply..."; 66 replyElement.text = "waiting for reply...";
67 67
68 // get the last letter on the button (assuming the button text is, for 68 // get the last letter on the button (assuming the button text is, for
69 // example, "send message to A". 69 // example, "send message to A".
70 String buttonText = e.currentTarget.dynamic.attributes["value"]; 70 String buttonText = e.currentTarget.dynamic.attributes["value"];
71 String isolateName = buttonText[buttonText.length - 1]; 71 String isolateName = buttonText[buttonText.length - 1];
72 String greeting = document.query("#greetingText").dynamic.value; 72 String greeting = document.query("#greetingText").dynamic.value;
73 var message = { "id": MessageId.GREETING, "args" : [ greeting ] }; 73 var message = { "id": MessageId.GREETING, "args" : [ greeting ] };
74 ports[isolateName].call(message).receive( 74 ports[isolateName].call(message).then((var msg) {
75 (var msg, SendPort replyTo) { 75 replyElement.text = msg;
76 replyElement.text = msg;
77 }); 76 });
78 }); 77 });
79 } 78 }
80 79
81 chirpPort.receive((var message, SendPort replyTo) { 80 chirpPort.receive((var message, SendPort replyTo) {
82 replyElement.text = message; 81 replyElement.text = message;
83 }); 82 });
84 } 83 }
85 84
86 static void main() { 85 static void main() {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 "received message: <span class='messageText'>'${message}'</span>"; 144 "received message: <span class='messageText'>'${message}'</span>";
146 if (div.query(".replyCheckbox").dynamic.checked) { 145 if (div.query(".replyCheckbox").dynamic.checked) {
147 InputElement element = div.query(".delayTextbox"); 146 InputElement element = div.query(".delayTextbox");
148 int millis = Math.parseInt(element.value); 147 int millis = Math.parseInt(element.value);
149 window.setTimeout(() { 148 window.setTimeout(() {
150 replyTo.send("this is a reply from isolate '${isolateName}'", null); 149 replyTo.send("this is a reply from isolate '${isolateName}'", null);
151 }, millis); 150 }, millis);
152 } 151 }
153 } 152 }
154 } 153 }
OLDNEW
« no previous file with comments | « runtime/vm/snapshot_test.dart ('k') | samples/leap/leap_leg.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698