[libcxx-commits] [libcxx] 21a1a26 - [libc++][NFC] Define functor's call operator inline

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 27 11:20:49 PDT 2020


Author: Louis Dionne
Date: 2020-08-27T14:20:34-04:00
New Revision: 21a1a263a6d9c0c44ef8eb0744786e2aa5d59e53

URL: https://github.com/llvm/llvm-project/commit/21a1a263a6d9c0c44ef8eb0744786e2aa5d59e53
DIFF: https://github.com/llvm/llvm-project/commit/21a1a263a6d9c0c44ef8eb0744786e2aa5d59e53.diff

LOG: [libc++][NFC] Define functor's call operator inline

This fixes a mismatched visibility attribute on the call operator in
addition to making the code clearer. Given this is a simple lambda
in essence, the intent has always been to give it inline visibility.

Added: 
    

Modified: 
    libcxx/include/__threading_support

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__threading_support b/libcxx/include/__threading_support
index 072c4c7bcc89..6501217c2741 100644
--- a/libcxx/include/__threading_support
+++ b/libcxx/include/__threading_support
@@ -278,24 +278,21 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
 #endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 
 struct __libcpp_timed_backoff_policy {
-  _LIBCPP_THREAD_ABI_VISIBILITY
-  bool operator()(chrono::nanoseconds __elapsed) const;
+  _LIBCPP_INLINE_VISIBILITY
+  bool operator()(chrono::nanoseconds __elapsed) const
+  {
+      if(__elapsed > chrono::milliseconds(128))
+          __libcpp_thread_sleep_for(chrono::milliseconds(8));
+      else if(__elapsed > chrono::microseconds(64))
+          __libcpp_thread_sleep_for(__elapsed / 2);
+      else if(__elapsed > chrono::microseconds(4))
+        __libcpp_thread_yield();
+      else
+        ; // poll
+      return false;
+  }
 };
 
-inline _LIBCPP_INLINE_VISIBILITY
-bool __libcpp_timed_backoff_policy::operator()(chrono::nanoseconds __elapsed) const
-{
-    if(__elapsed > chrono::milliseconds(128))
-        __libcpp_thread_sleep_for(chrono::milliseconds(8));
-    else if(__elapsed > chrono::microseconds(64))
-        __libcpp_thread_sleep_for(__elapsed / 2);
-    else if(__elapsed > chrono::microseconds(4))
-      __libcpp_thread_yield();
-    else
-      ; // poll
-    return false;
-}
-
 static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64;
 
 template<class _Fn, class _BFn>


        


More information about the libcxx-commits mailing list