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

Unified Diff: corelib/src/implementation/stopwatch_implementation.dart

Issue 8537011: Rename StopWatch to Stopwatch. Add new Stopwatch.start() and Stopwatch.reset(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move break on new line. Created 9 years, 1 month 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 | corelib/src/stopwatch.dart » ('j') | corelib/src/stopwatch.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: corelib/src/implementation/stopwatch_implementation.dart
diff --git a/corelib/src/implementation/stopwatch_implementation.dart b/corelib/src/implementation/stopwatch_implementation.dart
index 231f4a8cd79a1d6d9c51abcc92a69e5f14834fab..e4c4115e3a3f94e0a62c1855bef98c2713c7b8f8 100644
--- a/corelib/src/implementation/stopwatch_implementation.dart
+++ b/corelib/src/implementation/stopwatch_implementation.dart
@@ -3,17 +3,20 @@
// BSD-style license that can be found in the LICENSE file.
/**
- * A simple implementation of the [StopWatch] interface.
+ * A simple implementation of the [Stopwatch] interface.
*/
-class StopWatchImplementation implements StopWatch {
+class StopwatchImplementation implements Stopwatch {
// The _start and _stop fields capture the time when [start] and [stop]
// are called respectively.
- // If _start is null, then the [StopWatch] has not been started yet.
- // If _stop is null, then the [StopWatch] has not been stopped yet.
+ // If _start is null, then the [Stopwatch] has not been started yet.
+ // If _stop is null, then the [Stopwatch] has not been stopped yet.
int _start;
int _stop;
- StopWatchImplementation() : _start = null, _stop = null {}
+ StopwatchImplementation() : _start = null, _stop = null {}
+ StopwatchImplementation.start() : _start = null, _stop = null {
+ start();
+ }
void start() {
if (_start === null) {
@@ -36,6 +39,14 @@ class StopWatchImplementation implements StopWatch {
_stop = Clock.now();
}
+ void reset() {
+ if (_start === null) return;
+ _start = Clock.now();
Ivan Posva 2011/11/11 16:31:54 A comment why it is OK to not set _start to null w
floitsch 2011/11/14 13:55:59 Done.
+ if (_stop !== null) {
+ _stop = _start;
+ }
+ }
+
int elapsed() {
if (_start === null) {
return 0;
« no previous file with comments | « no previous file | corelib/src/stopwatch.dart » ('j') | corelib/src/stopwatch.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698