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

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

Issue 9289042: Minor changes to the dart:io library files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // While we are already handling callbacks we will not notify the event 92 // While we are already handling callbacks we will not notify the event
93 // handler. _handleTimeout will call _notifyEventHandler once all pending 93 // handler. _handleTimeout will call _notifyEventHandler once all pending
94 // timers are processed. 94 // timers are processed.
95 return; 95 return;
96 } 96 }
97 97
98 if (_timers.firstEntry() === null) { 98 if (_timers.firstEntry() === null) {
99 // No pending timers: Close the receive port and let the event handler 99 // No pending timers: Close the receive port and let the event handler
100 // know. 100 // know.
101 if (_receivePort !== null) { 101 if (_receivePort !== null) {
102 EventHandler._sendData(-1, _receivePort, _NO_TIMER); 102 _EventHandler._sendData(-1, _receivePort, _NO_TIMER);
103 _shutdownTimerHandler(); 103 _shutdownTimerHandler();
104 } 104 }
105 } else { 105 } else {
106 if (_receivePort === null) { 106 if (_receivePort === null) {
107 // Create a receive port and register a message handler for the timer 107 // Create a receive port and register a message handler for the timer
108 // events. 108 // events.
109 _createTimerHandler(); 109 _createTimerHandler();
110 } 110 }
111 EventHandler._sendData(-1, 111 _EventHandler._sendData(-1,
112 _receivePort, 112 _receivePort,
113 _timers.firstEntry().element._wakeupTime); 113 _timers.firstEntry().element._wakeupTime);
114 } 114 }
115 } 115 }
116 116
117 117
118 // Creates a receive port and registers the timer handler on that 118 // Creates a receive port and registers the timer handler on that
119 // receive port. 119 // receive port.
120 void _createTimerHandler() { 120 void _createTimerHandler() {
121 121
122 void _handleTimeout() { 122 void _handleTimeout() {
123 int currentTime = (new Date.now()).value + _TIMER_JITTER; 123 int currentTime = (new Date.now()).value + _TIMER_JITTER;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 static ReceivePort _receivePort; 174 static ReceivePort _receivePort;
175 static bool _handling_callbacks = false; 175 static bool _handling_callbacks = false;
176 176
177 var _callback; 177 var _callback;
178 int _milliSeconds; 178 int _milliSeconds;
179 int _wakeupTime; 179 int _wakeupTime;
180 bool _repeating; 180 bool _repeating;
181 } 181 }
182 182
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698