16 #ifndef ABSL_SYNCHRONIZATION_INTERNAL_WAITER_H_ 17 #define ABSL_SYNCHRONIZATION_INTERNAL_WAITER_H_ 25 #ifdef ABSL_HAVE_SEMAPHORE_H 26 #include <semaphore.h> 36 #define ABSL_WAITER_MODE_FUTEX 0 37 #define ABSL_WAITER_MODE_SEM 1 38 #define ABSL_WAITER_MODE_CONDVAR 2 39 #define ABSL_WAITER_MODE_WIN32 3 41 #if defined(ABSL_FORCE_WAITER_MODE) 42 #define ABSL_WAITER_MODE ABSL_FORCE_WAITER_MODE 44 #define ABSL_WAITER_MODE ABSL_WAITER_MODE_WIN32 45 #elif defined(__linux__) 46 #define ABSL_WAITER_MODE ABSL_WAITER_MODE_FUTEX 47 #elif defined(ABSL_HAVE_SEMAPHORE_H) 48 #define ABSL_WAITER_MODE ABSL_WAITER_MODE_SEM 50 #define ABSL_WAITER_MODE ABSL_WAITER_MODE_CONDVAR 54 namespace synchronization_internal {
85 "Insufficient space for Waiter");
90 #ifndef THREAD_SANITIZER 96 static const int kIdlePeriods = 1;
100 #if ABSL_WAITER_MODE == ABSL_WAITER_MODE_FUTEX 103 std::atomic<int32_t> futex_;
104 static_assert(
sizeof(int32_t) ==
sizeof(futex_),
"Wrong size for futex");
106 #elif ABSL_WAITER_MODE == ABSL_WAITER_MODE_CONDVAR 112 #elif ABSL_WAITER_MODE == ABSL_WAITER_MODE_SEM 117 std::atomic<int> wakeups_;
119 #elif ABSL_WAITER_MODE == ABSL_WAITER_MODE_WIN32 127 using SRWLockStorage =
128 typename std::aligned_storage<sizeof(void*), alignof(void*)>::type;
129 using ConditionVariableStorage =
130 typename std::aligned_storage<sizeof(void*), alignof(void*)>::type;
136 SRWLockStorage mu_storage_;
137 ConditionVariableStorage cv_storage_;
142 #error Unknown ABSL_WAITER_MODE 149 #endif // ABSL_SYNCHRONIZATION_INTERNAL_WAITER_H_ bool Wait(KernelTimeout t)
std::atomic< int > wakeup_count_
Waiter & operator=(const Waiter &)=delete
std::atomic< int > waiter_count_
static const int kIdlePeriods
struct absl::base_internal::ThreadIdentity::WaiterState waiter_state
static Waiter * GetWaiter(base_internal::ThreadIdentity *identity)