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

Side by Side Diff: tools/dom/src/Timer.dart

Issue 13328002: Quiclk fix: it is a future. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 part of html; 5 part of html;
6 6
7 // TODO(antonm): support not DOM isolates too. 7 // TODO(antonm): support not DOM isolates too.
8 class _Timer implements Timer { 8 class _Timer implements Timer {
9 final canceller; 9 final canceller;
10 10
(...skipping 19 matching lines...) Expand all
30 }; 30 };
31 31
32 class _PureIsolateTimer implements Timer { 32 class _PureIsolateTimer implements Timer {
33 final ReceivePort _port = new ReceivePort(); 33 final ReceivePort _port = new ReceivePort();
34 SendPort _sendPort; // Effectively final. 34 SendPort _sendPort; // Effectively final.
35 35
36 _PureIsolateTimer(int milliSeconds, callback, repeating) { 36 _PureIsolateTimer(int milliSeconds, callback, repeating) {
37 _sendPort = _port.toSendPort(); 37 _sendPort = _port.toSendPort();
38 _port.receive((msg, replyTo) { 38 _port.receive((msg, replyTo) {
39 assert(msg == _TIMER_PING); 39 assert(msg == _TIMER_PING);
40 assert(replyTo == _HELPER_ISOLATE_PORT);
41 callback(this); 40 callback(this);
42 if (!repeating) _cancel(); 41 if (!repeating) _cancel();
43 }); 42 });
44 _HELPER_ISOLATE_PORT.then((port) { 43 _HELPER_ISOLATE_PORT.then((port) {
45 port.send([_NEW_TIMER, milliSeconds, repeating], _sendPort); 44 port.send([_NEW_TIMER, milliSeconds, repeating], _sendPort);
46 }); 45 });
47 } 46 }
48 47
49 void cancel() { 48 void cancel() {
50 _cancel(); 49 _cancel();
51 _HELPER_ISOLATE_PORT.then((port) { 50 _HELPER_ISOLATE_PORT.then((port) {
52 port.send([_CANCEL_TIMER], _sendPort); 51 port.send([_CANCEL_TIMER], _sendPort);
53 }); 52 });
54 } 53 }
55 54
56 void _cancel() { 55 void _cancel() {
57 _port.close(); 56 _port.close();
58 } 57 }
59 } 58 }
60 59
61 get _pureIsolateTimerFactoryClosure => 60 get _pureIsolateTimerFactoryClosure =>
62 ((int milliSeconds, void callback(Timer time), bool repeating) => 61 ((int milliSeconds, void callback(Timer time), bool repeating) =>
63 new _PureIsolateTimer(milliSeconds, callback, repeating)); 62 new _PureIsolateTimer(milliSeconds, callback, repeating));
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698