8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 18:43:02 +01:00

Use when possible much better way to delay thread execution

This commit is contained in:
alexpeshkoff 2009-02-04 11:36:53 +00:00
parent 1ce93bf480
commit d899da951d
2 changed files with 27 additions and 2 deletions

View File

@ -593,6 +593,7 @@ if test "$ac_cv_func_gettimeofday" = "yes"; then
#endif])
fi
AC_CHECK_FUNCS(time times)
AC_CHECK_FUNCS(nanosleep)
AC_SEARCH_LIBS(gethostname,nsl)
AC_SEARCH_LIBS(connect,socket)
AC_CHECK_FUNCS(strcasecmp stricmp)

View File

@ -44,6 +44,16 @@
#include <unistd.h>
#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#ifdef SOLARIS_MT
#include <thread.h>
@ -101,12 +111,26 @@ void THD_sleep(ULONG milliseconds)
* of milliseconds.
*
**************************************/
#ifdef WIN_NT
#if defined(WIN_NT)
SleepEx(milliseconds, FALSE);
#elif defined(HAVE_NANOSLEEP)
timespec timer, rem;
timer.tv_sec = milliseconds / 1000;
timer.tv_nsec = (milliseconds % 1000) * 1000000;
while (nanosleep(&timer, &rem) != 0)
{
if (errno != EINTR)
{
timer = rem;
continue;
}
Firebird::system_call_failed::raise("nanosleep");
}
#else
Firebird::Semaphore timer;
timer.tryEnter(0, milliseconds);
#endif // WIN_NT
#endif
}