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

Unified Diff: runtime/lib/timer_impl.dart

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/internal_patch.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/timer_impl.dart
diff --git a/runtime/lib/timer_impl.dart b/runtime/lib/timer_impl.dart
index d4a8160d1e8632727b05679c287a4bbc6f060a68..a0660e1f557b196bab3f1d3414f65b49ab7dbed8 100644
--- a/runtime/lib/timer_impl.dart
+++ b/runtime/lib/timer_impl.dart
@@ -172,7 +172,7 @@ class _Timer implements Timer {
// to nearest millisecond, not up, so that time + duration is before
// duration milliseconds from now. Using microsecond timers like
// Stopwatch allows detecting that the timer fires early.
- int now = new DateTime.now().millisecondsSinceEpoch;
+ int now = VMLibraryHooks.timerMillisecondClock();
int wakeupTime = (milliSeconds == 0) ? now : (now + 1 + milliSeconds);
_Timer timer = new _Timer._internal(callback,
@@ -232,7 +232,7 @@ class _Timer implements Timer {
if (_milliSeconds > 0) {
_wakeupTime += _milliSeconds;
} else {
- _wakeupTime = new DateTime.now().millisecondsSinceEpoch;
+ _wakeupTime = VMLibraryHooks.timerMillisecondClock();
}
}
@@ -340,7 +340,7 @@ class _Timer implements Timer {
} else {
// Collect pending timers from the timer heap which have expired at this
// time.
- var currentTime = new DateTime.now().millisecondsSinceEpoch;
+ var currentTime = VMLibraryHooks.timerMillisecondClock();
var timer;
while (!_heap.isEmpty && (_heap.first._wakeupTime <= currentTime)) {
timer = _heap.removeFirst();
« no previous file with comments | « runtime/lib/internal_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698