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

Side by Side Diff: runtime/bin/eventhandler_macos.cc

Issue 1519563003: Use a monotonic clock in the implementation of Timer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « runtime/bin/eventhandler_android.cc ('k') | runtime/bin/eventhandler_patch.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "bin/eventhandler.h" 8 #include "bin/eventhandler.h"
9 #include "bin/eventhandler_macos.h" 9 #include "bin/eventhandler_macos.h"
10 10
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 HandleInterruptFd(); 387 HandleInterruptFd();
388 } 388 }
389 } 389 }
390 390
391 391
392 int64_t EventHandlerImplementation::GetTimeout() { 392 int64_t EventHandlerImplementation::GetTimeout() {
393 if (!timeout_queue_.HasTimeout()) { 393 if (!timeout_queue_.HasTimeout()) {
394 return kInfinityTimeout; 394 return kInfinityTimeout;
395 } 395 }
396 int64_t millis = timeout_queue_.CurrentTimeout() - 396 int64_t millis = timeout_queue_.CurrentTimeout() -
397 TimerUtils::GetCurrentTimeMilliseconds(); 397 TimerUtils::GetCurrentMonotonicMillis();
398 return (millis < 0) ? 0 : millis; 398 return (millis < 0) ? 0 : millis;
399 } 399 }
400 400
401 401
402 void EventHandlerImplementation::HandleTimeout() { 402 void EventHandlerImplementation::HandleTimeout() {
403 if (timeout_queue_.HasTimeout()) { 403 if (timeout_queue_.HasTimeout()) {
404 int64_t millis = timeout_queue_.CurrentTimeout() - 404 int64_t millis = timeout_queue_.CurrentTimeout() -
405 TimerUtils::GetCurrentTimeMilliseconds(); 405 TimerUtils::GetCurrentMonotonicMillis();
406 if (millis <= 0) { 406 if (millis <= 0) {
407 DartUtils::PostNull(timeout_queue_.CurrentPort()); 407 DartUtils::PostNull(timeout_queue_.CurrentPort());
408 timeout_queue_.RemoveCurrent(); 408 timeout_queue_.RemoveCurrent();
409 } 409 }
410 } 410 }
411 } 411 }
412 412
413 413
414 void EventHandlerImplementation::EventHandlerEntry(uword args) { 414 void EventHandlerImplementation::EventHandlerEntry(uword args) {
415 static const intptr_t kMaxEvents = 16; 415 static const intptr_t kMaxEvents = 16;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 481
482 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 482 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
483 // The hashmap does not support keys with value 0. 483 // The hashmap does not support keys with value 0.
484 return dart::Utils::WordHash(fd + 1); 484 return dart::Utils::WordHash(fd + 1);
485 } 485 }
486 486
487 } // namespace bin 487 } // namespace bin
488 } // namespace dart 488 } // namespace dart
489 489
490 #endif // defined(TARGET_OS_MACOS) 490 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_android.cc ('k') | runtime/bin/eventhandler_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698