OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart.io; | 5 part of dart.io; |
6 | 6 |
7 class _Timer implements Timer { | 7 class _Timer implements Timer { |
8 // Set jitter to wake up timer events that would happen in _TIMER_JITTER ms. | 8 // Set jitter to wake up timer events that would happen in _TIMER_JITTER ms. |
9 static const int _TIMER_JITTER = 0; | 9 static const int _TIMER_JITTER = 0; |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 timer._repeating = repeating; | 25 timer._repeating = repeating; |
26 timer._addTimerToList(); | 26 timer._addTimerToList(); |
27 timer._notifyEventHandler(); | 27 timer._notifyEventHandler(); |
28 return timer; | 28 return timer; |
29 } | 29 } |
30 | 30 |
31 factory _Timer(int milliSeconds, void callback(Timer timer)) { | 31 factory _Timer(int milliSeconds, void callback(Timer timer)) { |
32 return _createTimer(callback, milliSeconds, false); | 32 return _createTimer(callback, milliSeconds, false); |
33 } | 33 } |
34 | 34 |
35 factory _Timer.repeating(int milliSeconds, void callback(Timer timer)) { | 35 factory _Timer.periodic(int milliSeconds, void callback(Timer timer)) { |
36 return _createTimer(callback, milliSeconds, true); | 36 return _createTimer(callback, milliSeconds, true); |
37 } | 37 } |
38 | 38 |
39 _Timer._internal() {} | 39 _Timer._internal() {} |
40 | 40 |
41 void _clear() { | 41 void _clear() { |
42 _callback = null; | 42 _callback = null; |
43 _milliSeconds = 0; | 43 _milliSeconds = 0; |
44 _wakeupTime = 0; | 44 _wakeupTime = 0; |
45 _repeating = false; | 45 _repeating = false; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 int _milliSeconds; | 186 int _milliSeconds; |
187 int _wakeupTime; | 187 int _wakeupTime; |
188 bool _repeating; | 188 bool _repeating; |
189 } | 189 } |
190 | 190 |
191 // Provide a closure which will allocate a Timer object to be able to hook | 191 // Provide a closure which will allocate a Timer object to be able to hook |
192 // up the Timer interface in dart:isolate with the implementation here. | 192 // up the Timer interface in dart:isolate with the implementation here. |
193 _getTimerFactoryClosure() { | 193 _getTimerFactoryClosure() { |
194 return (int milliSeconds, void callback(Timer timer), bool repeating) { | 194 return (int milliSeconds, void callback(Timer timer), bool repeating) { |
195 if (repeating) { | 195 if (repeating) { |
196 return new _Timer.repeating(milliSeconds, callback); | 196 return new _Timer.periodic(milliSeconds, callback); |
197 } | 197 } |
198 return new _Timer(milliSeconds, callback); | 198 return new _Timer(milliSeconds, callback); |
199 }; | 199 }; |
200 } | 200 } |
201 | 201 |
202 | 202 |
OLD | NEW |