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

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

Issue 12218131: Combine window.setTimeout/setInterval with Timer and Timer.repeating. Also (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 // TODO(justinfagnani): use Timer when it works in isolates in dart2js 78 new Timer(new Duration(milliseconds: millis), () {
79 // see: http://dartbug.com/4997
80 window.setTimeout(() {
81 replyTo.send('this is a reply from isolate "${isolateName}"', null); 79 replyTo.send('this is a reply from isolate "${isolateName}"', null);
82 }, millis); 80 });
83 } 81 }
84 } 82 }
85 83
86 port.receive((message, SendPort replyTo) { 84 port.receive((message, SendPort replyTo) {
87 switch(message['id']) { 85 switch(message['id']) {
88 case MessageId.INIT: 86 case MessageId.INIT:
89 init(message['args'][0], message['args'][1]); 87 init(message['args'][0], message['args'][1]);
90 break; 88 break;
91 case MessageId.GREETING: 89 case MessageId.GREETING:
92 greeting(message['args'][0], replyTo); 90 greeting(message['args'][0], replyTo);
(...skipping 26 matching lines...) Expand all
119 ports[isolateName].call(message).then((var msg) { 117 ports[isolateName].call(message).then((var msg) {
120 replyElement.text = msg; 118 replyElement.text = msg;
121 }); 119 });
122 }); 120 });
123 } 121 }
124 122
125 port.receive((var message, SendPort replyTo) { 123 port.receive((var message, SendPort replyTo) {
126 replyElement.text = message; 124 replyElement.text = message;
127 }); 125 });
128 } 126 }
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