[libcxx-commits] [PATCH] D98015: [libcxx] Simplify rounding of durations in win32 __libcpp_thread_sleep_for

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 5 00:56:54 PST 2021

mstorsjo created this revision.
mstorsjo added reviewers: libc++, curdeius.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added 1 blocking reviewer(s): libc++.

Also fix a comment typo.

This mirrors what was suggested in review of D97539 <https://reviews.llvm.org/D97539>.

  rG LLVM Github Monorepo



Index: libcxx/src/support/win32/thread_win32.cpp
--- libcxx/src/support/win32/thread_win32.cpp
+++ libcxx/src/support/win32/thread_win32.cpp
@@ -246,10 +246,8 @@
 void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
-  using namespace chrono;
-  // round-up to the nearest milisecond
-  milliseconds __ms =
-      duration_cast<milliseconds>(__ns + chrono::nanoseconds(999999));
+  // round-up to the nearest millisecond
+  chrono::milliseconds __ms = std::chrono::ceil<chrono::milliseconds>(__ns);
   // FIXME(compnerd) this should be an alertable sleep (WFSO or SleepEx)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98015.328424.patch
Type: text/x-patch
Size: 684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210305/6ed251f0/attachment.bin>

More information about the libcxx-commits mailing list