| Index: sdk/lib/core/stopwatch.dart
|
| diff --git a/sdk/lib/core/stopwatch.dart b/sdk/lib/core/stopwatch.dart
|
| index 7d8ce334cd1d1c8a748af7295813cb22d1bf7776..b446069f70c1ad298a441051ec28816114d9149a 100644
|
| --- a/sdk/lib/core/stopwatch.dart
|
| +++ b/sdk/lib/core/stopwatch.dart
|
| @@ -63,6 +63,11 @@ abstract class Stopwatch {
|
| * Returns the frequency of the elapsed counter in Hz.
|
| */
|
| int get frequency;
|
| +
|
| + /**
|
| + * Returns wether the [StopWatch] is currently running.
|
| + */
|
| + bool get isRunning;
|
| }
|
|
|
| class _StopwatchImpl implements Stopwatch {
|
| @@ -77,14 +82,12 @@ class _StopwatchImpl implements Stopwatch {
|
| _StopwatchImpl() : _start = null, _stop = null {}
|
|
|
| void start() {
|
| + if (isRunning) return;
|
| if (_start == null) {
|
| // This stopwatch has never been started.
|
| _start = _now();
|
| } else {
|
| - if (_stop == null) {
|
| - return;
|
| - }
|
| - // Restarting this stopwatch. Prepend the elapsed time to the current
|
| + // Restart this stopwatch. Prepend the elapsed time to the current
|
| // start time.
|
| _start = _now() - (_stop - _start);
|
| _stop = null;
|
| @@ -92,9 +95,7 @@ class _StopwatchImpl implements Stopwatch {
|
| }
|
|
|
| void stop() {
|
| - if (_start == null || _stop != null) {
|
| - return;
|
| - }
|
| + if (!isRunning) return;
|
| _stop = _now();
|
| }
|
|
|
| @@ -127,6 +128,8 @@ class _StopwatchImpl implements Stopwatch {
|
|
|
| int get frequency => _frequency();
|
|
|
| + bool get isRunning => _start != null && _stop == null;
|
| +
|
| external static int _frequency();
|
| external static int _now();
|
| }
|
|
|