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

Unified Diff: runtime/vm/os_linux.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
« no previous file with comments | « runtime/vm/os_android.cc ('k') | runtime/vm/os_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/os_linux.cc
diff --git a/runtime/vm/os_linux.cc b/runtime/vm/os_linux.cc
index ed1d6685f627a660510662893cb7e3d61354d1e6..97e9e553b2ebad3b44ef4a32d1781cb5053eefef 100644
--- a/runtime/vm/os_linux.cc
+++ b/runtime/vm/os_linux.cc
@@ -404,8 +404,29 @@ 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) {
+ struct timespec req; // requested.
+ struct timespec rem; // remainder.
+ int64_t seconds = micros / kMicrosecondsPerSecond;
+ micros = micros - seconds * kMicrosecondsPerSecond;
+ int64_t nanos = micros * kNanosecondsPerMicrosecond;
+ req.tv_sec = seconds;
+ req.tv_nsec = nanos;
+ while (true) {
+ int r = nanosleep(&req, &rem);
+ if (r == 0) {
+ break;
+ }
+ // We should only ever see an interrupt error.
+ ASSERT(errno == EINTR);
+ // Copy remainder into requested and repeat.
+ req = rem;
+ }
}
« no previous file with comments | « runtime/vm/os_android.cc ('k') | runtime/vm/os_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698