[PATCH] D29630: [libcxx] Threading support: externalize sleep_for()
Asiri Rathnayake via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 7 06:19:29 PST 2017
rmaprath added inline comments.
================
Comment at: include/__threading_support:593
+ using namespace chrono;
+ milliseconds ms = duration_cast<milliseconds>(ns);
+ if (ms.count() == 0 || ns > duration_cast<nanoseconds>(ms))
----------------
joerg wrote:
> Use (ns + 999999) so that the cast rounds up.
So, this code was lifted from the sources as-is. I will do this change, I think it makes sense.
================
Comment at: include/__threading_support:594
+ milliseconds ms = duration_cast<milliseconds>(ns);
+ if (ms.count() == 0 || ns > duration_cast<nanoseconds>(ms))
+ ++ms;
----------------
joerg wrote:
> Why is ns == 0 supposed to sleep at all? In fact, the caller already ensures that can't happen?
IIUC, this is trying to detect round-downs and then compensate for it. With the above suggestion, this should no longer be needed. Will get rid of it as well.
https://reviews.llvm.org/D29630
More information about the cfe-commits
mailing list