Remove final flush logic
[m6w6/libmemcached] / libtest / wait.h
index c6c3f966d84a79fcbddd9f167cc515d8e3992be1..f81a29ad85e0762d5124af8908cf3c52a9207464 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <unistd.h>
 #include <string>
+#include <signal.h>
 
 #include <libtest/dream.h>
 
@@ -63,6 +64,30 @@ public:
     }
   }
 
+  Wait(const pid_t &_pid_arg, uint32_t timeout= 6) :
+    _successful(false)
+  {
+    uint32_t waited;
+    uint32_t this_wait;
+    uint32_t retry;
+
+    for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
+    {
+      if (kill(_pid_arg, 0) == 0)
+      {
+        _successful= true;
+        break;
+      }
+      else if (waited >= timeout)
+      {
+        break;
+      }
+
+      this_wait= retry * retry / 3 + 1;
+      libtest::dream(this_wait, 0);
+    }
+  }
+
   bool successful() const
   {
     return _successful;