<div dir="auto"><span style="font-family:sans-serif;font-size:13.696px">Yup, that sounds better.</span><div dir="auto" style="font-family:sans-serif;font-size:13.696px"><br></div><div dir="auto" style="font-family:sans-serif;font-size:13.696px">I'll put up a patch soon.</div><div dir="auto" style="font-family:sans-serif;font-size:13.696px"><br></div><div dir="auto" style="font-family:sans-serif;font-size:13.696px">Cheers,</div><div dir="auto" style="font-family:sans-serif;font-size:13.696px"><br></div><div dir="auto" style="font-family:sans-serif;font-size:13.696px">/ Asiri</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 7 Jan 2017 9:18 p.m., "Saleem Abdulrasool" <<a href="mailto:compnerd@compnerd.org">compnerd@compnerd.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I would really rather not introduce a `__libcpp_thread_nanosleep`. Different systems may have different granularities for their sleep. A `__libcpp_sleep_for(std::<wbr>chrono::duration)` sounds reasonable however.<br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 6, 2017 at 11:53 PM, Asiri Rathnayake <span dir="ltr"><<a href="mailto:asiri.rathnayake@gmail.com" target="_blank">asiri.rathnayake@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Wouldn't it be better to introduce a __libcpp_thread_nanosleep() API call here?<div dir="auto"><br></div><div dir="auto">I bumped into a similar issue with a custom thread implementation and have a downstream patch like that.</div><div dir="auto"><br></div><div dir="auto">Cheers,</div><div dir="auto"><br></div><div dir="auto">/ Asiri</div><div dir="auto"><br></div></div><div class="m_1711232237719341507HOEnZb"><div class="m_1711232237719341507h5"><div class="gmail_extra"><br><div class="gmail_quote">On 7 Jan 2017 2:59 a.m., "Saleem Abdulrasool via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="m_1711232237719341507m_-3186227476921306972quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: compnerd<br>
Date: Fri Jan 6 20:48:30 2017<br>
New Revision: 291331<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=291331&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=291331&view=rev</a><br>
Log:<br>
thread: implement sleep_for on Windows<br>
<br>
Windows does not provide an implementation of `nanosleep`. Round up the<br>
time duration to the nearest ms and use `Sleep`. Although this may<br>
over-sleep, there is no hard real-time guarantee on the wake, so<br>
sleeping a bit more is better than under-sleeping as it within the<br>
specification.<br>
<br>
Modified:<br>
libcxx/trunk/src/thread.cpp<br>
<br>
Modified: libcxx/trunk/src/thread.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/thread.cpp?rev=291331&r1=291330&r2=291331&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/libcxx/trunk/src/thread.<wbr>cpp?rev=291331&r1=291330&r2=29<wbr>1331&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/thread.cpp (original)<br>
+++ libcxx/trunk/src/thread.cpp Fri Jan 6 20:48:30 2017<br>
@@ -117,6 +117,12 @@ sleep_for(const chrono::nanoseconds& ns)<br>
using namespace chrono;<br>
if (ns > nanoseconds::zero())<br>
{<br>
+#if defined(_LIBCPP_WIN32API)<br>
+ milliseconds ms = duration_cast<milliseconds>(ns<wbr>);<br>
+ if (ns > duration_cast<nanoseconds>(ms)<wbr>)<br>
+ ++ms;<br>
+ Sleep(ms.count());<br>
+#else<br>
seconds s = duration_cast<seconds>(ns);<br>
timespec ts;<br>
typedef decltype(ts.tv_sec) ts_sec;<br>
@@ -134,6 +140,7 @@ sleep_for(const chrono::nanoseconds& ns)<br>
<br>
while (nanosleep(&ts, &ts) == -1 && errno == EINTR)<br>
;<br>
+#endif<br>
}<br>
}<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_1711232237719341507gmail_signature" data-smartmail="gmail_signature">Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org</div>
</div></div>
</blockquote></div></div>