| OLD | NEW |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 callback(this); | 45 callback(this); |
| 46 if (!repeating) _cancel(); | 46 if (!repeating) _cancel(); |
| 47 }); | 47 }); |
| 48 _HELPER_ISOLATE_PORT.then((port) { | 48 _HELPER_ISOLATE_PORT.then((port) { |
| 49 port.send([_NEW_TIMER, milliSeconds, repeating], _sendPort); | 49 port.send([_NEW_TIMER, milliSeconds, repeating], _sendPort); |
| 50 }); | 50 }); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void cancel() { | 53 void cancel() { |
| 54 _cancel(); | 54 _cancel(); |
| 55 _HELPER_ISOLATE_PORT.send([_CANCEL_TIMER], _sendPort); | 55 _HELPER_ISOLATE_PORT.then((port) { |
| 56 port.send([_CANCEL_TIMER], _sendPort); |
| 57 }); |
| 56 } | 58 } |
| 57 | 59 |
| 58 void _cancel() { | 60 void _cancel() { |
| 59 _port.close(); | 61 _port.close(); |
| 60 } | 62 } |
| 61 | 63 |
| 62 static final Future<SendPort> _HELPER_ISOLATE_PORT = | 64 static final Future<SendPort> _HELPER_ISOLATE_PORT = |
| 63 spawnDomFunction(_helperIsolateMain); | 65 spawnDomFunction(_helperIsolateMain); |
| 64 } | 66 } |
| 65 | 67 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 77 new Timer(duration, callback); | 79 new Timer(duration, callback); |
| 78 } else if (cmd == _CANCEL_TIMER) { | 80 } else if (cmd == _CANCEL_TIMER) { |
| 79 _TIMER_REGISTRY.remove(replyTo).cancel(); | 81 _TIMER_REGISTRY.remove(replyTo).cancel(); |
| 80 } | 82 } |
| 81 }); | 83 }); |
| 82 } | 84 } |
| 83 | 85 |
| 84 get _pureIsolateTimerFactoryClosure => | 86 get _pureIsolateTimerFactoryClosure => |
| 85 ((int milliSeconds, void callback(Timer time), bool repeating) => | 87 ((int milliSeconds, void callback(Timer time), bool repeating) => |
| 86 new _PureIsolateTimer(milliSeconds, callback, repeating)); | 88 new _PureIsolateTimer(milliSeconds, callback, repeating)); |
| OLD | NEW |