[PATCH] D29630: [libcxx] Threading support: externalize sleep_for()
Joerg Sonnenberger via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 7 06:05:53 PST 2017
joerg added inline comments.
================
Comment at: include/__threading_support:367
+ ts.tv_sec = ts_sec_max;
+ ts.tv_nsec = giga::num - 1;
+ }
----------------
I don't think giga::num makes things any clear compared to just spelling it out.
================
Comment at: include/__threading_support:593
+ using namespace chrono;
+ milliseconds ms = duration_cast<milliseconds>(ns);
+ if (ms.count() == 0 || ns > duration_cast<nanoseconds>(ms))
----------------
Use (ns + 999999) so that the cast rounds up.
================
Comment at: include/__threading_support:594
+ milliseconds ms = duration_cast<milliseconds>(ns);
+ if (ms.count() == 0 || ns > duration_cast<nanoseconds>(ms))
+ ++ms;
----------------
Why is ns == 0 supposed to sleep at all? In fact, the caller already ensures that can't happen?
https://reviews.llvm.org/D29630
More information about the cfe-commits
mailing list