File indexing completed on 2026-05-03 08:14:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H
0011 #define _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H
0012
0013 #include <__config>
0014
0015 #if _LIBCPP_HAS_THREADS
0016
0017 # include <__chrono/duration.h>
0018 # include <__thread/support.h>
0019
0020 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0021 # pragma GCC system_header
0022 # endif
0023
0024 _LIBCPP_BEGIN_NAMESPACE_STD
0025
0026 struct __libcpp_timed_backoff_policy {
0027 _LIBCPP_HIDE_FROM_ABI bool operator()(chrono::nanoseconds __elapsed) const {
0028 if (__elapsed > chrono::milliseconds(128))
0029 __libcpp_thread_sleep_for(chrono::milliseconds(8));
0030 else if (__elapsed > chrono::microseconds(64))
0031 __libcpp_thread_sleep_for(__elapsed / 2);
0032 else if (__elapsed > chrono::microseconds(4))
0033 __libcpp_thread_yield();
0034 else {
0035 }
0036 return false;
0037 }
0038 };
0039
0040 _LIBCPP_END_NAMESPACE_STD
0041
0042 #endif
0043
0044 #endif