+/// timed_wait() waits for msec milliseconds. It is mainly an helper to wrap
+/// conversion from milliseconds to struct timespec, as used by pthreads.
+
+void timed_wait(WaitCondition& sleepCond, Lock& sleepLock, int msec) {
+
+#if defined(_WIN32) || defined(_WIN64)
+ int tm = msec;
+#else
+ timespec ts, *tm = &ts;
+ uint64_t ms = Time::current_time().msec() + msec;
+
+ ts.tv_sec = ms / 1000;
+ ts.tv_nsec = (ms % 1000) * 1000000LL;
+#endif
+
+ cond_timedwait(sleepCond, sleepLock, tm);
+}
+
+