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

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

Issue 18325006: Add isActive field on Timer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments. Created 7 years, 6 months 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 | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/lib/async/timer_isActive_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 73c7cae1c12ccad966449f43d93515a138917c10..6e56e3e1550a413549cfe5f0da4b0b86f1b78437 100644
--- a/sdk/lib/io/timer_impl.dart
+++ b/sdk/lib/io/timer_impl.dart
@@ -50,6 +50,7 @@ class _Timer extends LinkedListEntry<_Timer> implements Timer {
bool get _repeating => _milliSeconds >= 0;
+ bool get isActive => _callback != null;
// Cancels a set timer. The timer is removed from the timer list and if
// the given timer is the earliest timer the native timer is reset.
@@ -143,7 +144,12 @@ class _Timer extends LinkedListEntry<_Timer> implements Timer {
// one of the later timers which will set the callback to
// null.
if (timer._callback != null) {
- timer._callback(timer);
+ var callback = timer._callback;
+ if (!timer._repeating) {
+ //Mark timer as inactive.
+ timer._callback = null;
+ }
+ callback(timer);
// Re-insert repeating timer if not canceled.
if (timer._repeating && timer._callback != null) {
timer._advanceWakeupTime();
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/lib/async/timer_isActive_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698