Removed ::Sleep and implemented Utility::Sleep.

This commit is contained in:
Gunnar Beutner 2012-09-25 15:41:43 +02:00
parent e1fc41e735
commit edf812b6b5
6 changed files with 19 additions and 15 deletions

View 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;

View 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(); ) {

View File

@ -20,20 +20,9 @@
#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.
*

View 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);

View 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 */
}

View File

@ -50,6 +50,8 @@ public:
static pid_t GetPid(void);
static void Sleep(double timeout);
private:
static bool m_SSLInitialized;