summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libcxx/src/thread.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/libcxx/src/thread.cpp b/libcxx/src/thread.cpp
index 4fb1dd21fc2..290e2aef983 100644
--- a/libcxx/src/thread.cpp
+++ b/libcxx/src/thread.cpp
@@ -117,6 +117,12 @@ sleep_for(const chrono::nanoseconds& ns)
using namespace chrono;
if (ns > nanoseconds::zero())
{
+#if defined(_LIBCPP_WIN32API)
+ milliseconds ms = duration_cast<milliseconds>(ns);
+ if (ns > duration_cast<nanoseconds>(ms))
+ ++ms;
+ Sleep(ms.count());
+#else
seconds s = duration_cast<seconds>(ns);
timespec ts;
typedef decltype(ts.tv_sec) ts_sec;
@@ -134,6 +140,7 @@ sleep_for(const chrono::nanoseconds& ns)
while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
;
+#endif
}
}
OpenPOWER on IntegriCloud