break;
default:
+ struct timespec ts = {0, 200000000};
for (int i = 0; i < 120 * 5; i++)
{
if (access(startFile.c_str(), F_OK) == 0)
unlink(startFile.c_str());
exit(1);
}
- usleep(200000);
+ nanosleep(&ts, NULL);
}
unlink(startFile.c_str());
exit(1);
-#include <unistd.h>
#include <pthread.h>
+#include <ctime>
#include <cstring>
#include "common.h"
while (nonstop)
{
#ifdef STG_TIMER_DEBUG
- usleep(1000000 / TIME_SPEED);
+ struct timespec ts = {0, 1000000000 / TIME_SPEED};
+ nanosleep(&ts);
+ //usleep(1000000 / TIME_SPEED);
stgTime++;
#else
+ struct timespec ts = {0, 500000000};
+ nanosleep(&ts);
+ //usleep(500000);
stgTime = time(NULL);
- usleep(500000);
#endif
}
isTimerRunning = false;
int stgUsleep(unsigned long t)
{
#ifdef STG_TIMER_DEBUG
-return usleep(t / TIME_SPEED);
+struct timespec ts = {(t / TIME_SPEED) / 1000000, ((t / TIME_SPEED) % 1000000) * 1000};
+return nanosleep(&ts);
+//return usleep(t / TIME_SPEED);
#else
-return usleep(t);
+struct timespec ts = {t / 1000000, (t % 1000000) * 1000};
+return nanosleep(&ts);
+//return usleep(t);
#endif
}
//-----------------------------------------------------------------------------
stgUsleep(200000);
}
//-----------------------------------------------------------------------------
-
-
users->CloseSearch(h);
//5 seconds to thread stops itself
+struct timespec ts = {0, 200000000};
for (int i = 0; i < 25 && !stopped; i++)
{
- usleep(200000);
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now kill it
int c = 0;
time_t touchTime = stgTime - MONITOR_TIME_DELAY_SEC;
-
+struct timespec ts = {0, 500000000};
while (tc->running)
{
- usleep(500000);
+ nanosleep(&ts, 0);
if (!tc->running)
{
tc->FlushAndRemove();
nonstop = false;
//5 seconds to thread stops itself
-unsigned i;
-for (i = 0; i < 25 * (users.size() / 50 + 1); i++)
+struct timespec ts = {0, 200000000};
+for (size_t i = 0; i < 25 * (users.size() / 50 + 1); i++)
{
if (!isRunning)
break;
- usleep(200000);
+ nanosleep(&ts, NULL);
}
//after 5 seconds waiting thread still running. now kill it