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

Unified Diff: corelib/unified/coreimpl/stopwatch.dart

Issue 10837219: Port the remaining of dart:coreimpl to the unified corelib. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review fixes. Created 8 years, 4 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 | « corelib/unified/coreimpl/options.dart ('k') | lib/compiler/implementation/lib/clock.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: corelib/unified/coreimpl/stopwatch.dart
diff --git a/corelib/src/implementation/stopwatch_implementation.dart b/corelib/unified/coreimpl/stopwatch.dart
similarity index 76%
copy from corelib/src/implementation/stopwatch_implementation.dart
copy to corelib/unified/coreimpl/stopwatch.dart
index 1316a27fd9573d051e20c49993e779ba244b898c..581ca561f41661aa32412bb91a9b7fa87e1e9fc6 100644
--- a/corelib/src/implementation/stopwatch_implementation.dart
+++ b/corelib/unified/coreimpl/stopwatch.dart
@@ -22,14 +22,14 @@ class StopwatchImplementation implements Stopwatch {
void start() {
if (_start === null) {
// This stopwatch has never been started.
- _start = Clock.now();
+ _start = _Clock.now();
} else {
if (_stop === null) {
return;
}
// Restarting this stopwatch. Prepend the elapsed time to the current
// start time.
- _start = Clock.now() - (_stop - _start);
+ _start = _Clock.now() - (_stop - _start);
_stop = null;
}
}
@@ -38,14 +38,14 @@ class StopwatchImplementation implements Stopwatch {
if (_start === null || _stop !== null) {
return;
}
- _stop = Clock.now();
+ _stop = _Clock.now();
}
void reset() {
if (_start === null) return;
// If [_start] is not null, then the stopwatch had already been started. It
// may running right now.
- _start = Clock.now();
+ _start = _Clock.now();
if (_stop !== null) {
// The watch is not running. So simply set the [_stop] to [_start] thus
// having an elapsed time of 0.
@@ -57,7 +57,7 @@ class StopwatchImplementation implements Stopwatch {
if (_start === null) {
return 0;
}
- return (_stop === null) ? (Clock.now() - _start) : (_stop - _start);
+ return (_stop === null) ? (_Clock.now() - _start) : (_stop - _start);
}
int elapsedInUs() {
@@ -69,7 +69,23 @@ class StopwatchImplementation implements Stopwatch {
}
int frequency() {
- return Clock.frequency();
+ return _Clock.frequency();
}
+}
+
+/**
+ * The class [_Clock] provides access to a monotonically incrementing clock
+ * device.
+ */
+class _Clock {
+
+ /**
+ * Returns the current clock tick.
+ */
+ external static int now();
+ /**
+ * Returns the frequency of clock ticks in Hz.
+ */
+ external static int frequency();
}
« no previous file with comments | « corelib/unified/coreimpl/options.dart ('k') | lib/compiler/implementation/lib/clock.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698