| OLD | NEW |
| 1 // Copyright (c) 2012, 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 |
| 11 // Disables the timer. | 11 // Disables the timer. |
| 12 static const int _NO_TIMER = -1; | 12 static const int _NO_TIMER = -1; |
| 13 | 13 |
| 14 static Timer _createTimer(void callback(Timer timer), | 14 static Timer _createTimer(void callback(Timer timer), |
| 15 int milliSeconds, | 15 int milliSeconds, |
| 16 bool repeating) { | 16 bool repeating) { |
| 17 _EventHandler._start(); | 17 _EventHandler._start(); |
| 18 if (_timers == null) { | 18 if (_timers == null) { |
| 19 _timers = new DoubleLinkedQueue<_Timer>(); | 19 _timers = new DoubleLinkedQueue<_Timer>(); |
| 20 } | 20 } |
| 21 Timer timer = new _Timer._internal(); | 21 _Timer timer = new _Timer._internal(); |
| 22 timer._callback = callback; | 22 timer._callback = callback; |
| 23 timer._milliSeconds = milliSeconds; | 23 timer._milliSeconds = milliSeconds; |
| 24 timer._wakeupTime = (new DateTime.now()).millisecondsSinceEpoch + milliSecon
ds; | 24 timer._wakeupTime = (new DateTime.now()).millisecondsSinceEpoch + milliSecon
ds; |
| 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)) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.repeating(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 |