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