Changeset: faba80cc5b66 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=faba80cc5b66
Modified Files:
        configure.ag
        gdk/gdk_posix.c
Branch: Apr2019
Log Message:

Use nanosleep() if available, and turn MS_sleep_ms(1) into sleeping 1 usec.
On Windows, the smallest sleep granularity is milliseconds, so no
change there, but on Linux, we translate a sleep of 1 ms into a sleep
of 1 microsecond (not nanosecond).


diffs (35 lines):

diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2623,6 +2623,7 @@ AC_CHECK_FUNCS([\
        lockf \
        madvise \
        mremap \
+       nanosleep \
        nl_langinfo \
        _NSGetExecutablePath \
        pipe2 \
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -1099,11 +1099,15 @@ win_mkdir(const char *pathname, const in
 void
 MT_sleep_ms(unsigned int ms)
 {
-       struct timeval tv;
-
-       tv.tv_sec = ms / 1000;
-       tv.tv_usec = 1000 * (ms % 1000);
-       (void) select(0, NULL, NULL, NULL, &tv);
+#ifdef HAVE_NANOSLEEP
+       (void) nanosleep(&(struct timespec) {.tv_sec = ms / 1000,
+                               .tv_nsec = ms == 1 ? 1000 : (long) (ms % 1000) 
* 1000000,},
+               NULL);
+#else
+       (void) select(0, NULL, NULL, NULL,
+                     &(struct timeval) {.tv_sec = ms / 1000,
+                                     .tv_usec = ms == 1 ? 1 : (ms % 1000) * 
1000,});
+#endif
 }
 
 #else /* WIN32 */
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to