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

Unified Diff: runtime/vm/os_android.cc

Issue 109803002: Profiler Take 2 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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: runtime/vm/os_android.cc
diff --git a/runtime/vm/os_android.cc b/runtime/vm/os_android.cc
index cbce25ca67d10640334bbc620cb1a1e947415494..75b823599b3da966e27d10adde83823f9b3bf6d9 100644
--- a/runtime/vm/os_android.cc
+++ b/runtime/vm/os_android.cc
@@ -319,8 +319,22 @@ int OS::NumberOfAvailableProcessors() {
void OS::Sleep(int64_t millis) {
- // TODO(5411554): For now just use usleep we may have to revisit this.
- usleep(millis * 1000);
+ int64_t micros = millis * kMicrosecondsPerMillisecond;
+ SleepMicros(micros);
+}
+
+
+void OS::SleepMicros(int64_t micros) {
+ // We must loop here because SIGPROF will interrupt usleep.
+ int64_t start = GetCurrentTimeMicros();
+ while (micros > 0) {
+ usleep(micros);
+ int64_t now = GetCurrentTimeMicros();
+ int64_t delta = now - start;
+ ASSERT(delta >= 0);
+ start = now;
+ micros -= delta;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698