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

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

Issue 98233005: Only notify event-handler when there is an earlier timer in the timer queue. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | no next file » | 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 1d7b277c2189463e6d1bec90dcfc38e32c687dc4..f03b6180e5e17c2c3c1788fb387e46da667e4565 100644
--- a/sdk/lib/io/timer_impl.dart
+++ b/sdk/lib/io/timer_impl.dart
@@ -29,7 +29,10 @@ class _Timer extends LinkedListEntry<_Timer> implements Timer {
}
timer._milliSeconds = repeating ? milliSeconds : -1;
timer._addTimerToList();
- timer._notifyEventHandler();
+ if (identical(timer, _timers.first)) {
+ // The new timer is the first in queue. Update event handler.
+ timer._notifyEventHandler();
+ }
return timer;
}
@@ -72,9 +75,8 @@ class _Timer extends LinkedListEntry<_Timer> implements Timer {
_wakeupTime += _milliSeconds;
}
- // Adds a timer to the timer list and resets the native timer if it is the
- // earliest timer in the list. Timers with the same wakeup time are enqueued
- // in order and notified in FIFO order.
+ // Adds a timer to the timer list. Timers with the same wakeup time are
+ // enqueued in order and notified in FIFO order.
void _addTimerToList() {
_Timer entry = _timers.isEmpty ? null : _timers.first;
while (entry != null) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698