Go to the documentation of this file.00001 #ifndef MT_UTIL_H
00002 #define MT_UTIL_H
00003
00004 #if (defined(_MSC_VER))
00005 #include <windows.h>
00006 #elif (defined(__MINGW32__))
00007 #include <windows.h>
00008 #elif (defined(__linux__))
00009 #include <unistd.h>
00010 #else
00011 #include <unistd.h>
00012
00013 #endif
00014
00015 namespace mt
00016 {
00017
00018 inline void sleep_ms(unsigned int msecs)
00019 {
00020 #if (defined(_MSC_VER))
00021 Sleep(DWORD(msecs));
00022 #elif (defined(__MINGW32__))
00023 Sleep(DWORD(msecs));
00024 #elif (defined(__linux__))
00025 const unsigned int secs = ((unsigned int)(msecs / 1000));
00026 const unsigned long usecs = ((unsigned long)((msecs % 1000) * 1000));
00027
00028 sleep(secs);
00029 usleep(usecs);
00030 #else
00031 const unsigned int secs = ((unsigned int)(msecs / 1000));
00032 const unsigned long usecs = ((unsigned long)((msecs % 1000) * 1000));
00033
00034 sleep(secs);
00035 usleep(usecs);
00036 #endif
00037 }
00038
00039 }
00040
00041 #endif // MT_UTIL_H