mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 16:03:03 +01:00
Use when possible much better way to delay thread execution
This commit is contained in:
parent
1ce93bf480
commit
d899da951d
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user