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

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

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « samples/dartcombat/player.dart ('k') | samples/logo/logo.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library isolate_sample; 5 library isolate_sample;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'dart:isolate'; 8 import 'dart:isolate';
9 import 'dart:math';
10 9
11 /* 10 /*
12 * This is a simple sample application showing how to create two isolates 11 * This is a simple sample application showing how to create two isolates
13 * and send messages to them, and receive replies back. 12 * and send messages to them, and receive replies back.
14 */ 13 */
15 14
16 /** 15 /**
17 * These are the messages we are going to send to the isolates that we create. 16 * These are the messages we are going to send to the isolates that we create.
18 */ 17 */
19 class MessageId { 18 class MessageId {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 67
69 /** 68 /**
70 * Display the message we received, and send back a simple reply (unless 69 * Display the message we received, and send back a simple reply (unless
71 * the user has unchecked the reply checkbox). 70 * the user has unchecked the reply checkbox).
72 */ 71 */
73 void greeting(String message, SendPort replyTo) { 72 void greeting(String message, SendPort replyTo) {
74 div.query('.messageBox').innerHtml = 73 div.query('.messageBox').innerHtml =
75 'received message: <span class="messageText">"${message}"</span>'; 74 'received message: <span class="messageText">"${message}"</span>';
76 if (div.query('input.replyCheckbox').checked) { 75 if (div.query('input.replyCheckbox').checked) {
77 InputElement element = div.query('.delayTextbox'); 76 InputElement element = div.query('.delayTextbox');
78 int millis = parseInt(element.value); 77 int millis = int.parse(element.value);
79 // TODO(justinfagnani): use Timer when it works in isolates in dart2js 78 // TODO(justinfagnani): use Timer when it works in isolates in dart2js
80 // see: http://dartbug.com/4997 79 // see: http://dartbug.com/4997
81 window.setTimeout(() { 80 window.setTimeout(() {
82 replyTo.send('this is a reply from isolate "${isolateName}"', null); 81 replyTo.send('this is a reply from isolate "${isolateName}"', null);
83 }, millis); 82 }, millis);
84 } 83 }
85 } 84 }
86 85
87 port.receive((message, SendPort replyTo) { 86 port.receive((message, SendPort replyTo) {
88 switch(message['id']) { 87 switch(message['id']) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 ports[isolateName].call(message).then((var msg) { 119 ports[isolateName].call(message).then((var msg) {
121 replyElement.text = msg; 120 replyElement.text = msg;
122 }); 121 });
123 }); 122 });
124 } 123 }
125 124
126 port.receive((var message, SendPort replyTo) { 125 port.receive((var message, SendPort replyTo) {
127 replyElement.text = message; 126 replyElement.text = message;
128 }); 127 });
129 } 128 }
OLDNEW
« no previous file with comments | « samples/dartcombat/player.dart ('k') | samples/logo/logo.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698