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

Side by Side Diff: runtime/bin/timer_impl.dart

Issue 9597015: Update Timer API to take the callback as the last parameter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | « runtime/bin/timer.dart ('k') | samples/actors/core/actors-term.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 class _Timer implements Timer { 5 class _Timer implements Timer {
6 // Set jitter to wake up timer events that would happen in _TIMER_JITTER ms. 6 // Set jitter to wake up timer events that would happen in _TIMER_JITTER ms.
7 static final int _TIMER_JITTER = 0; 7 static final int _TIMER_JITTER = 0;
8 8
9 // Disables the timer. 9 // Disables the timer.
10 static final int _NO_TIMER = -1; 10 static final int _NO_TIMER = -1;
11 11
12 static Timer _createTimer(void callback(Timer timer), 12 static Timer _createTimer(void callback(Timer timer),
13 int milliSeconds, 13 int milliSeconds,
14 bool repeating) { 14 bool repeating) {
15 _EventHandler._start(); 15 _EventHandler._start();
16 if (_timers === null) { 16 if (_timers === null) {
17 _timers = new DoubleLinkedQueue<_Timer>(); 17 _timers = new DoubleLinkedQueue<_Timer>();
18 } 18 }
19 Timer timer = new _Timer._internal(); 19 Timer timer = new _Timer._internal();
20 timer._callback = callback; 20 timer._callback = callback;
21 timer._milliSeconds = milliSeconds; 21 timer._milliSeconds = milliSeconds;
22 timer._wakeupTime = (new Date.now()).value + milliSeconds; 22 timer._wakeupTime = (new Date.now()).value + milliSeconds;
23 timer._repeating = repeating; 23 timer._repeating = repeating;
24 timer._addTimerToList(); 24 timer._addTimerToList();
25 timer._notifyEventHandler(); 25 timer._notifyEventHandler();
26 return timer; 26 return timer;
27 } 27 }
28 28
29 factory _Timer(void callback(Timer timer), int milliSeconds) { 29 factory _Timer(int milliSeconds, void callback(Timer timer)) {
30 return _createTimer(callback, milliSeconds, false); 30 return _createTimer(callback, milliSeconds, false);
31 } 31 }
32 32
33 factory _Timer.repeating(void callback(Timer timer), int milliSeconds) { 33 factory _Timer.repeating(int milliSeconds, void callback(Timer timer)) {
34 return _createTimer(callback, milliSeconds, true); 34 return _createTimer(callback, milliSeconds, true);
35 } 35 }
36 36
37 _Timer._internal() {} 37 _Timer._internal() {}
38 38
39 void _clear() { 39 void _clear() {
40 _callback = null; 40 _callback = null;
41 _milliSeconds = 0; 41 _milliSeconds = 0;
42 _wakeupTime = 0; 42 _wakeupTime = 0;
43 _repeating = false; 43 _repeating = false;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 static ReceivePort _receivePort; 179 static ReceivePort _receivePort;
180 static bool _handling_callbacks = false; 180 static bool _handling_callbacks = false;
181 181
182 var _callback; 182 var _callback;
183 int _milliSeconds; 183 int _milliSeconds;
184 int _wakeupTime; 184 int _wakeupTime;
185 bool _repeating; 185 bool _repeating;
186 } 186 }
187 187
OLDNEW
« no previous file with comments | « runtime/bin/timer.dart ('k') | samples/actors/core/actors-term.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698