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

Unified Diff: runtime/bin/utils_macos.cc

Issue 25909002: Sampling profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « runtime/bin/utils_linux.cc ('k') | runtime/platform/thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/utils_macos.cc
diff --git a/runtime/bin/utils_macos.cc b/runtime/bin/utils_macos.cc
index c47feddf830425eec9c97a6cbbe5720b65bd5ce1..1c83afd508465f482d5f828bb6f4111e1230fa19 100644
--- a/runtime/bin/utils_macos.cc
+++ b/runtime/bin/utils_macos.cc
@@ -98,7 +98,17 @@ int64_t TimerUtils::GetCurrentTimeMicros() {
}
void TimerUtils::Sleep(int64_t millis) {
- usleep(millis * 1000);
+ // We must loop here because SIGPROF will interrupt usleep.
+ int64_t micros = millis * 1000;
+ 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;
+ }
}
} // namespace bin
« no previous file with comments | « runtime/bin/utils_linux.cc ('k') | runtime/platform/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698