From 21a1a263a6d9c0c44ef8eb0744786e2aa5d59e53 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 27 Aug 2020 13:09:23 -0400 Subject: [PATCH] [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. --- libcxx/include/__threading_support | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) 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