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

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

Issue 12258020: Reverting setTimeout removal. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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/setup.dart ('k') | samples/swarm/App.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 9
10 /* 10 /*
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 /** 68 /**
69 * 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
70 * the user has unchecked the reply checkbox). 70 * the user has unchecked the reply checkbox).
71 */ 71 */
72 void greeting(String message, SendPort replyTo) { 72 void greeting(String message, SendPort replyTo) {
73 div.query('.messageBox').innerHtml = 73 div.query('.messageBox').innerHtml =
74 'received message: <span class="messageText">"${message}"</span>'; 74 'received message: <span class="messageText">"${message}"</span>';
75 if (div.query('input.replyCheckbox').checked) { 75 if (div.query('input.replyCheckbox').checked) {
76 InputElement element = div.query('.delayTextbox'); 76 InputElement element = div.query('.delayTextbox');
77 int millis = int.parse(element.value); 77 int millis = int.parse(element.value);
78 new Timer(new Duration(milliseconds: millis), () { 78 // TODO(justinfagnani): use Timer when it works in isolates in dart2js
79 // see: http://dartbug.com/4997
80 window.setTimeout(() {
79 replyTo.send('this is a reply from isolate "${isolateName}"', null); 81 replyTo.send('this is a reply from isolate "${isolateName}"', null);
80 }); 82 }, millis);
81 } 83 }
82 } 84 }
83 85
84 port.receive((message, SendPort replyTo) { 86 port.receive((message, SendPort replyTo) {
85 switch(message['id']) { 87 switch(message['id']) {
86 case MessageId.INIT: 88 case MessageId.INIT:
87 init(message['args'][0], message['args'][1]); 89 init(message['args'][0], message['args'][1]);
88 break; 90 break;
89 case MessageId.GREETING: 91 case MessageId.GREETING:
90 greeting(message['args'][0], replyTo); 92 greeting(message['args'][0], replyTo);
(...skipping 26 matching lines...) Expand all
117 ports[isolateName].call(message).then((var msg) { 119 ports[isolateName].call(message).then((var msg) {
118 replyElement.text = msg; 120 replyElement.text = msg;
119 }); 121 });
120 }); 122 });
121 } 123 }
122 124
123 port.receive((var message, SendPort replyTo) { 125 port.receive((var message, SendPort replyTo) {
124 replyElement.text = message; 126 replyElement.text = message;
125 }); 127 });
126 } 128 }
OLDNEW
« no previous file with comments | « samples/dartcombat/setup.dart ('k') | samples/swarm/App.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698