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

Side by Side Diff: sdk/lib/io/timer_impl.dart

Issue 11770004: Rename Date to DateTime. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments and keep Backwards-compatibility class Date. Created 7 years, 11 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/io/secure_socket.dart ('k') | tests/compiler/dart2js_extra/mirror_test.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 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 Date.now()).millisecondsSinceEpoch + milliSeconds; 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)) {
32 return _createTimer(callback, milliSeconds, false); 32 return _createTimer(callback, milliSeconds, false);
33 } 33 }
34 34
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 } 117 }
118 118
119 119
120 // Creates a receive port and registers the timer handler on that 120 // Creates a receive port and registers the timer handler on that
121 // receive port. 121 // receive port.
122 void _createTimerHandler() { 122 void _createTimerHandler() {
123 123
124 void _handleTimeout() { 124 void _handleTimeout() {
125 int currentTime = 125 int currentTime =
126 (new Date.now()).millisecondsSinceEpoch + _TIMER_JITTER; 126 (new DateTime.now()).millisecondsSinceEpoch + _TIMER_JITTER;
127 127
128 // Collect all pending timers. 128 // Collect all pending timers.
129 DoubleLinkedQueueEntry<_Timer> entry = _timers.firstEntry(); 129 DoubleLinkedQueueEntry<_Timer> entry = _timers.firstEntry();
130 var pending_timers = new List(); 130 var pending_timers = new List();
131 while (entry != null) { 131 while (entry != null) {
132 _Timer timer = entry.element; 132 _Timer timer = entry.element;
133 if (timer._wakeupTime <= currentTime) { 133 if (timer._wakeupTime <= currentTime) {
134 entry.remove(); 134 entry.remove();
135 pending_timers.addLast(timer); 135 pending_timers.addLast(timer);
136 entry = _timers.firstEntry(); 136 entry = _timers.firstEntry();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « sdk/lib/io/secure_socket.dart ('k') | tests/compiler/dart2js_extra/mirror_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698