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

Unified Diff: sdk/lib/async/zone.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
Index: sdk/lib/async/zone.dart
diff --git a/sdk/lib/async/zone.dart b/sdk/lib/async/zone.dart
index 5f9fce92436f6543bbfc34eb9ebfa2eca0d58c34..bea3fc24b1ef6f245b169b59bc1eed7ffa415881 100644
--- a/sdk/lib/async/zone.dart
+++ b/sdk/lib/async/zone.dart
@@ -436,7 +436,6 @@ class _ZoneTimer implements Timer {
final _Zone _zone;
final _TimerCallback _callback;
Timer _timer;
- bool _isDone = false;
_ZoneTimer(this._zone, Duration duration, this._callback) {
_zone.expectCallback();
@@ -444,15 +443,15 @@ class _ZoneTimer implements Timer {
}
void _run() {
- _isDone = true;
_zone.executeCallbackGuarded(_callback);
}
void cancel() {
- if (!_isDone) _zone.cancelCallbackExpectation();
- _isDone = true;
+ if (_timer.isActive) _zone.cancelCallbackExpectation();
_timer.cancel();
}
+
+ bool get isActive => _timer.isActive;
}
typedef void _PeriodicTimerCallback(Timer timer);
@@ -464,7 +463,6 @@ class _PeriodicZoneTimer implements Timer {
final _Zone _zone;
final _PeriodicTimerCallback _callback;
Timer _timer;
- bool _isDone = false;
_PeriodicZoneTimer(this._zone, Duration duration, this._callback) {
_zone.expectCallback();
@@ -477,10 +475,11 @@ class _PeriodicZoneTimer implements Timer {
}
void cancel() {
- if (!_isDone) _zone.cancelCallbackExpectation();
- _isDone = true;
+ if (_timer.isActive) _zone.cancelCallbackExpectation();
_timer.cancel();
}
+
+ bool get isActive => _timer.isActive;
}
/**

Powered by Google App Engine
This is Rietveld 408576698