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 import 'dart:_internal' hide Symbol; | 5 import 'dart:_internal' hide Symbol; |
6 | 6 |
7 // Timer heap implemented as a array-based binary heap[0]. | 7 // Timer heap implemented as a array-based binary heap[0]. |
8 // This allows for O(1) `first`, O(log(n)) `remove`/`removeFirst` and O(log(n)) | 8 // This allows for O(1) `first`, O(log(n)) `remove`/`removeFirst` and O(log(n)) |
9 // `add`. | 9 // `add`. |
10 // | 10 // |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // Every zero timer gets its own event. | 237 // Every zero timer gets its own event. |
238 _notifyZeroHandler(); | 238 _notifyZeroHandler(); |
239 } else { | 239 } else { |
240 _heap.add(this); | 240 _heap.add(this); |
241 if (_heap.isFirst(this)) { | 241 if (_heap.isFirst(this)) { |
242 _notifyEventHandler(); | 242 _notifyEventHandler(); |
243 } | 243 } |
244 } | 244 } |
245 } | 245 } |
246 | 246 |
247 // Enqeue one message for each zero timer. To be able to distinguish from | 247 // Enqueue one message for each zero timer. To be able to distinguish from |
248 // EventHandler messages we send a _ZERO_EVENT instead of a _TIMEOUT_EVENT. | 248 // EventHandler messages we send a _ZERO_EVENT instead of a _TIMEOUT_EVENT. |
249 static void _notifyZeroHandler() { | 249 static void _notifyZeroHandler() { |
250 if (_sendPort == null) { | 250 if (_sendPort == null) { |
251 _createTimerHandler(); | 251 _createTimerHandler(); |
252 } | 252 } |
253 _sendPort.send(_ZERO_EVENT); | 253 _sendPort.send(_ZERO_EVENT); |
254 } | 254 } |
255 | 255 |
256 // Handle the notification of a zero timer. Make sure to also execute non-zero | 256 // Handle the notification of a zero timer. Make sure to also execute non-zero |
257 // timers with a lower expiration time. | 257 // timers with a lower expiration time. |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 if (repeating) { | 436 if (repeating) { |
437 return new _Timer.periodic(milliSeconds, callback); | 437 return new _Timer.periodic(milliSeconds, callback); |
438 } | 438 } |
439 return new _Timer(milliSeconds, callback); | 439 return new _Timer(milliSeconds, callback); |
440 } | 440 } |
441 } | 441 } |
442 | 442 |
443 _setupHooks() { | 443 _setupHooks() { |
444 VMLibraryHooks.timerFactory = _Timer._factory; | 444 VMLibraryHooks.timerFactory = _Timer._factory; |
445 } | 445 } |
OLD | NEW |