]> granicus.if.org Git - icinga2/commitdiff
Removed ::Sleep and implemented Utility::Sleep.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 25 Sep 2012 13:41:43 +0000 (15:41 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 25 Sep 2012 13:41:43 +0000 (15:41 +0200)
lib/base/application.cpp
lib/base/process.cpp
lib/base/unix.cpp
lib/base/unix.h
lib/base/utility.cpp
lib/base/utility.h

index 51458dda37d87da388dc8dc51a307adf8f00c0b6..5a423b804e4a046c37800cb6e80e69d6a2bd087f 100644 (file)
@@ -138,7 +138,7 @@ void Application::TimeWatchThreadProc(void)
        double lastLoop = Utility::GetTime();
 
        for (;;) {
-               Sleep(5000);
+               Utility::Sleep(5);
 
                double now = Utility::GetTime();
                double timeDiff = lastLoop - now;
index 0686d0c79670fdedfee8207077cd98997c4e8a5e..63c24117ee31e510807cd9c78518aeb239cdabc3 100644 (file)
@@ -81,7 +81,7 @@ void Process::WorkerThreadProc(void)
                        tv.tv_usec = 0;
                        select(nfds + 1, &readfds, NULL, NULL, &tv);
 #else /* _MSC_VER */
-                       Sleep(1000);
+                       Utility::Sleep(1);
 #endif /* _MSC_VER */
 
                        for (it = tasks.begin(); it != tasks.end(); ) {
index 8997e814e983d687c6c636f5abb27a7dd1279a99..010c390a02b9135b2633e31a093de385752ba93b 100644 (file)
 #include "i2-base.h"
 
 #ifndef _WIN32
-#include <ltdl.h>
 
 using namespace icinga;
 
-/**
- * Sleeps for the specified amount of time.
- *
- * @param milliseconds The amount of time in milliseconds.
- */
-void Sleep(unsigned long milliseconds)
-{
-       usleep(milliseconds * 1000);
-}
-
 /**
  * Closes a socket.
  *
index 31e5ae9c058538ac03208d653a84d7aa4f7f70d4..bc1f59e329eacd15f63186d13bb4a3616ead0634 100644 (file)
@@ -37,8 +37,6 @@
 #include <sys/file.h>
 #include <sys/wait.h>
 
-void Sleep(unsigned long milliseconds);
-
 typedef int SOCKET;
 #define INVALID_SOCKET (-1)
 void closesocket(SOCKET fd);
index b6c89282d78dc227e5cb2e27bafce83a44a58681..f3fe5fbf17aeb410c80a4add357b2014711dbe7d 100644 (file)
@@ -309,3 +309,18 @@ pid_t Utility::GetPid(void)
        return GetCurrentProcessId();
 #endif /* _WIN32 */
 }
+
+/**
+ * Sleeps for the specified amount of time.
+ *
+ * @param timeout The timeout in seconds.
+ */
+void Utility::Sleep(double timeout)
+{
+#ifndef _WIN32
+       usleep(timeout * 1000 * 1000);
+#else /* _WIN32 */
+       Sleep(timeout * 1000);
+#endif /* _WIN32 */
+}
+
index 96c914a377adb7a7f3b527f9580ea23750e9d03d..b1f5d00eac8dbee6b363eb703abd7908e4e79972 100644 (file)
@@ -50,6 +50,8 @@ public:
 
        static pid_t GetPid(void);
 
+       static void Sleep(double timeout);
+
 private:
        static bool m_SSLInitialized;