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

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

Issue 27215002: Very simple version of Isolates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 1 month 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/eventhandler.dart ('k') | sdk/lib/isolate/isolate.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) 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 RawReceivePort _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 _Timer timer = new _Timer._internal(); 24 _Timer timer = new _Timer._internal();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 156 }
157 } 157 }
158 } 158 }
159 } finally { 159 } finally {
160 _handling_callbacks = false; 160 _handling_callbacks = false;
161 _notifyEventHandler(); 161 _notifyEventHandler();
162 } 162 }
163 } 163 }
164 164
165 if(_receivePort == null) { 165 if(_receivePort == null) {
166 _receivePort = new ReceivePort(); 166 _receivePort = new RawReceivePort((_) { _handleTimeout(); });
167 _receivePort.receive((var message, ignored) {
168 _handleTimeout();
169 });
170 } 167 }
171 } 168 }
172 169
173 void _shutdownTimerHandler() { 170 void _shutdownTimerHandler() {
174 _receivePort.close(); 171 _receivePort.close();
175 _receivePort = null; 172 _receivePort = null;
176 } 173 }
177 } 174 }
178 175
179 // Provide a closure which will allocate a Timer object to be able to hook 176 // Provide a closure which will allocate a Timer object to be able to hook
180 // up the Timer interface in dart:isolate with the implementation here. 177 // up the Timer interface in dart:isolate with the implementation here.
181 _getTimerFactoryClosure() { 178 _getTimerFactoryClosure() {
182 return (int milliSeconds, void callback(Timer timer), bool repeating) { 179 return (int milliSeconds, void callback(Timer timer), bool repeating) {
183 if (repeating) { 180 if (repeating) {
184 return new _Timer.periodic(milliSeconds, callback); 181 return new _Timer.periodic(milliSeconds, callback);
185 } 182 }
186 return new _Timer(milliSeconds, callback); 183 return new _Timer(milliSeconds, callback);
187 }; 184 };
188 } 185 }
189 186
190 187
OLDNEW
« no previous file with comments | « sdk/lib/io/eventhandler.dart ('k') | sdk/lib/isolate/isolate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698