Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 StreamSubscription _subscription; | |
|
Ivan Posva
2013/10/24 06:48:38
Where is this _subscription used?
floitsch
2013/10/24 16:15:58
spurious code from the ReceivePort -> RawReceivePo
| |
| 15 static bool _handling_callbacks = false; | 16 static bool _handling_callbacks = false; |
| 16 | 17 |
| 17 Function _callback; | 18 Function _callback; |
| 18 int _milliSeconds; | 19 int _milliSeconds; |
| 19 int _wakeupTime; | 20 int _wakeupTime; |
| 20 | 21 |
| 21 static Timer _createTimer(void callback(Timer timer), | 22 static Timer _createTimer(void callback(Timer timer), |
| 22 int milliSeconds, | 23 int milliSeconds, |
| 23 bool repeating) { | 24 bool repeating) { |
| 24 _Timer timer = new _Timer._internal(); | 25 _Timer timer = new _Timer._internal(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 } | 157 } |
| 157 } | 158 } |
| 158 } | 159 } |
| 159 } finally { | 160 } finally { |
| 160 _handling_callbacks = false; | 161 _handling_callbacks = false; |
| 161 _notifyEventHandler(); | 162 _notifyEventHandler(); |
| 162 } | 163 } |
| 163 } | 164 } |
| 164 | 165 |
| 165 if(_receivePort == null) { | 166 if(_receivePort == null) { |
| 166 _receivePort = new ReceivePort(); | 167 _receivePort = new RawReceivePort((message) { _handleTimeout(); }); |
| 167 _receivePort.receive((var message, ignored) { | |
| 168 _handleTimeout(); | |
| 169 }); | |
| 170 } | 168 } |
| 171 } | 169 } |
| 172 | 170 |
| 173 void _shutdownTimerHandler() { | 171 void _shutdownTimerHandler() { |
| 174 _receivePort.close(); | 172 _receivePort.close(); |
| 175 _receivePort = null; | 173 _receivePort = null; |
| 176 } | 174 } |
| 177 } | 175 } |
| 178 | 176 |
| 179 // Provide a closure which will allocate a Timer object to be able to hook | 177 // 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. | 178 // up the Timer interface in dart:isolate with the implementation here. |
| 181 _getTimerFactoryClosure() { | 179 _getTimerFactoryClosure() { |
| 182 return (int milliSeconds, void callback(Timer timer), bool repeating) { | 180 return (int milliSeconds, void callback(Timer timer), bool repeating) { |
| 183 if (repeating) { | 181 if (repeating) { |
| 184 return new _Timer.periodic(milliSeconds, callback); | 182 return new _Timer.periodic(milliSeconds, callback); |
| 185 } | 183 } |
| 186 return new _Timer(milliSeconds, callback); | 184 return new _Timer(milliSeconds, callback); |
| 187 }; | 185 }; |
| 188 } | 186 } |
| 189 | 187 |
| 190 | 188 |
| OLD | NEW |