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

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

Issue 22901017: Always initialize the EventHandler in the standalone. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Simplify impl and don't call Stop (other isolates may still be running). Created 7 years, 4 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) 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 extends LinkedListEntry<_Timer> implements Timer { 7 class _Timer extends LinkedListEntry<_Timer> implements Timer {
8 // Disables the timer. 8 // Disables the timer.
9 static const int _NO_TIMER = -1; 9 static const int _NO_TIMER = -1;
10 10
11 // Timers are ordered by wakeup time. 11 // Timers are ordered by wakeup time.
12 static LinkedList<_Timer> _timers = new LinkedList<_Timer>(); 12 static LinkedList<_Timer> _timers = new LinkedList<_Timer>();
13 13
14 static ReceivePort _receivePort; 14 static ReceivePort _receivePort;
15 static bool _handling_callbacks = false; 15 static bool _handling_callbacks = false;
16 16
17 Function _callback; 17 Function _callback;
18 int _milliSeconds; 18 int _milliSeconds;
19 int _wakeupTime; 19 int _wakeupTime;
20 20
21 static Timer _createTimer(void callback(Timer timer), 21 static Timer _createTimer(void callback(Timer timer),
22 int milliSeconds, 22 int milliSeconds,
23 bool repeating) { 23 bool repeating) {
24 _EventHandler._start();
25 _Timer timer = new _Timer._internal(); 24 _Timer timer = new _Timer._internal();
26 timer._callback = callback; 25 timer._callback = callback;
27 timer._wakeupTime = 26 timer._wakeupTime =
28 new DateTime.now().millisecondsSinceEpoch + milliSeconds; 27 new DateTime.now().millisecondsSinceEpoch + milliSeconds;
29 timer._milliSeconds = repeating ? milliSeconds : -1; 28 timer._milliSeconds = repeating ? milliSeconds : -1;
30 timer._addTimerToList(); 29 timer._addTimerToList();
31 timer._notifyEventHandler(); 30 timer._notifyEventHandler();
32 return timer; 31 return timer;
33 } 32 }
34 33
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 _getTimerFactoryClosure() { 181 _getTimerFactoryClosure() {
183 return (int milliSeconds, void callback(Timer timer), bool repeating) { 182 return (int milliSeconds, void callback(Timer timer), bool repeating) {
184 if (repeating) { 183 if (repeating) {
185 return new _Timer.periodic(milliSeconds, callback); 184 return new _Timer.periodic(milliSeconds, callback);
186 } 185 }
187 return new _Timer(milliSeconds, callback); 186 return new _Timer(milliSeconds, callback);
188 }; 187 };
189 } 188 }
190 189
191 190
OLDNEW
« runtime/bin/eventhandler_macos.cc ('K') | « sdk/lib/io/eventhandler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698