]> git.cworth.org Git - apitrace/commitdiff
retrace: Sleep when polling for input.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 13 Oct 2012 08:27:07 +0000 (09:27 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 13 Oct 2012 08:34:39 +0000 (09:34 +0100)
As Carl Worth identified, if the user passed the "-w" option to beable
to see the last frame of the retrace, the glretrace would enter a
busy-waiting loop, consuming as much CPU as possible.

common/os_time.hpp
retrace/d3dretrace_main.cpp
retrace/glretrace_main.cpp

index 75175d85f6ecb15d8fc69622e10526b23ab5bb3d..13cc733ae05488312b4fb5554d08fcb8fd49bc2d 100644 (file)
 
 
 #if defined(_WIN32)
-#include <windows.h>
-#elif defined(__linux__)
-#include <time.h>
-#elif defined(__APPLE__)
-#include <mach/mach_time.h>
+#  include <windows.h>
 #else
-#include <sys/time.h>
+#  if defined(__linux__)
+#    include <time.h>
+#  elif defined(__APPLE__)
+#    include <mach/mach_time.h>
+#  else
+#    include <sys/time.h>
+#  endif
+#  include <unistd.h>
 #endif
 
 
@@ -88,6 +91,15 @@ namespace os {
 #endif
     }
 
+    // Suspend execution
+    inline void
+    sleep(unsigned long usecs) {
+#if defined(_WIN32)
+        Sleep((usecs + 999) / 1000);
+#else
+        usleep(usecs);
+#endif
+    }
 
 } /* namespace os */
 
index 40d53eafb1b946201a076cb996b8dddb5d12202e..9878fe3c87b059690527f6c6e44f523d72f4880d 100644 (file)
@@ -87,6 +87,7 @@ retrace::flushRendering(void) {
 
 void
 retrace::waitForInput(void) {
+    /* TODO */
 }
 
 void
index d857d03604b649ea145076da4367270dccc09f82..1086be9d42e72d5b26084d2964b13457e887207c 100755 (executable)
@@ -435,6 +435,7 @@ retrace::flushRendering(void) {
 void
 retrace::waitForInput(void) {
     while (glws::processEvents()) {
+        os::sleep(100*1000);
     }
 }