[libcxx-commits] [PATCH] D114109: [libc++] Enable <atomic> when threads are disabled

Nilay Vaish via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 17 12:24:52 PST 2021


nilayvaish accepted this revision.
nilayvaish added inline comments.


================
Comment at: libcxx/include/__config:1196
-     !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \
-     || defined(_LIBCPP_HAS_NO_THREADS)
 #  define _LIBCPP_HAS_NO_ATOMIC_HEADER
----------------
Do we know why this constraint on having atomics only when threads are enabled was put in place?


================
Comment at: libcxx/include/__thread/poll_with_backoff.h:39-44
+      if (__f())
+        return true; // _Fn completion means success
+      if (__count < __libcpp_polling_count) {
+        __count += 1;
+        continue;
+      }
----------------
I am feeling slightly strange about this code.  Do you think following would be better?

while (true) {
  while (count < polling_count) {
  // check __f
   count++;
  }
  // check elapsed time
  // check backoff policy.
}

Or the following two separate loop version:

while (count < polling_count) {
  // check __f
  count++;
}
while (!__f()) {
  // check elapsed time
  // check backoff policy.
}

This is just for discussion since the code here has been moved from another file.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114109/new/

https://reviews.llvm.org/D114109



More information about the libcxx-commits mailing list