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

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

Issue 13430008: Only use special method to send messages to helper isolate. (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 | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/src/native_DOMImplementation.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 part of html; 5 part of html;
6 6
7 // TODO(antonm): support not DOM isolates too.
8 class _Timer implements Timer { 7 class _Timer implements Timer {
9 final canceller; 8 final canceller;
10 9
11 _Timer(this.canceller); 10 _Timer(this.canceller);
12 11
13 void cancel() { canceller(); } 12 void cancel() { canceller(); }
14 } 13 }
15 14
16 get _timerFactoryClosure => (int milliSeconds, void callback(Timer timer), bool repeating) { 15 get _timerFactoryClosure => (int milliSeconds, void callback(Timer timer), bool repeating) {
17 var maker; 16 var maker;
(...skipping 30 matching lines...) Expand all
48 47
49 void cancel() { 48 void cancel() {
50 _cancel(); 49 _cancel();
51 _send([_CANCEL_TIMER]); 50 _send([_CANCEL_TIMER]);
52 } 51 }
53 52
54 void _cancel() { 53 void _cancel() {
55 _port.close(); 54 _port.close();
56 } 55 }
57 56
58 // Tricky part.
59 // Once _HELPER_ISOLATE_PORT gets resolved, it will still delay in .then
60 // and to delay Timer.run is used. However, Timer.run will try to register
61 // another Timer and here we got stuck: event cannot be posted as then
62 // callback is not executed because it's delayed with timer.
63 // Therefore once future is resolved, it's unsafe to call .then on it
64 // in Timer code.
65 _send(msg) { 57 _send(msg) {
66 if (_SEND_PORT != null) { 58 _sendToHelperIsolate(msg, _sendPort);
67 _SEND_PORT.send(msg, _sendPort);
68 } else {
69 _HELPER_ISOLATE_PORT.then((port) {
70 _SEND_PORT = port;
71 _SEND_PORT.send(msg, _sendPort);
72 });
73 }
74 } 59 }
75 } 60 }
76 61
77 get _pureIsolateTimerFactoryClosure => 62 get _pureIsolateTimerFactoryClosure =>
78 ((int milliSeconds, void callback(Timer time), bool repeating) => 63 ((int milliSeconds, void callback(Timer time), bool repeating) =>
79 new _PureIsolateTimer(milliSeconds, callback, repeating)); 64 new _PureIsolateTimer(milliSeconds, callback, repeating));
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/src/native_DOMImplementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698