File indexing completed on 2025-01-30 09:31:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ABSL_SYNCHRONIZATION_INTERNAL_FUTEX_WAITER_H_
0017 #define ABSL_SYNCHRONIZATION_INTERNAL_FUTEX_WAITER_H_
0018
0019 #include <atomic>
0020 #include <cstdint>
0021
0022 #include "absl/base/config.h"
0023 #include "absl/synchronization/internal/kernel_timeout.h"
0024 #include "absl/synchronization/internal/futex.h"
0025 #include "absl/synchronization/internal/waiter_base.h"
0026
0027 #ifdef ABSL_INTERNAL_HAVE_FUTEX
0028
0029 namespace absl {
0030 ABSL_NAMESPACE_BEGIN
0031 namespace synchronization_internal {
0032
0033 #define ABSL_INTERNAL_HAVE_FUTEX_WAITER 1
0034
0035 class FutexWaiter : public WaiterCrtp<FutexWaiter> {
0036 public:
0037 FutexWaiter() : futex_(0) {}
0038
0039 bool Wait(KernelTimeout t);
0040 void Post();
0041 void Poke();
0042
0043 static constexpr char kName[] = "FutexWaiter";
0044
0045 private:
0046
0047
0048 static int WaitUntil(std::atomic<int32_t>* v, int32_t val,
0049 KernelTimeout t);
0050
0051
0052
0053 std::atomic<int32_t> futex_;
0054 static_assert(sizeof(int32_t) == sizeof(futex_), "Wrong size for futex");
0055 };
0056
0057 }
0058 ABSL_NAMESPACE_END
0059 }
0060
0061 #endif
0062
0063 #endif