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

Unified Diff: sdk/lib/io/timer_impl.dart

Issue 96643003: Change Future.timeout callback to a named parameter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove dartium change, reduce safetyMargin for VM to 0. Created 7 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 | « no previous file | tests/lib/async/multiple_timer_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/timer_impl.dart
diff --git a/sdk/lib/io/timer_impl.dart b/sdk/lib/io/timer_impl.dart
index a3eb9529a360a177f4e13de35d6f599afc4a1095..883d09e42488bbefb6614636d2d12a9e363f82c4 100644
--- a/sdk/lib/io/timer_impl.dart
+++ b/sdk/lib/io/timer_impl.dart
@@ -24,8 +24,12 @@ class _Timer extends LinkedListEntry<_Timer> implements Timer {
_Timer timer = new _Timer._internal();
timer._callback = callback;
if (milliSeconds > 0) {
+ // Add one because DateTime.now() is assumed to round down
+ // to nearest millisecond, not up, so that time + duration is before
+ // duration milliseconds from now. Using micosecond timers like
+ // Stopwatch allows detecting that the timer fires early.
timer._wakeupTime =
- new DateTime.now().millisecondsSinceEpoch + milliSeconds;
+ new DateTime.now().millisecondsSinceEpoch + 1 + milliSeconds;
}
timer._milliSeconds = repeating ? milliSeconds : -1;
timer._addTimerToList();
« no previous file with comments | « no previous file | tests/lib/async/multiple_timer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698