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_SEM_WAITER_H_
0017 #define ABSL_SYNCHRONIZATION_INTERNAL_SEM_WAITER_H_
0018
0019 #include "absl/base/config.h"
0020
0021 #ifdef ABSL_HAVE_SEMAPHORE_H
0022 #include <semaphore.h>
0023
0024 #include <atomic>
0025 #include <cstdint>
0026
0027 #include "absl/base/internal/thread_identity.h"
0028 #include "absl/synchronization/internal/futex.h"
0029 #include "absl/synchronization/internal/kernel_timeout.h"
0030 #include "absl/synchronization/internal/waiter_base.h"
0031
0032 namespace absl {
0033 ABSL_NAMESPACE_BEGIN
0034 namespace synchronization_internal {
0035
0036 #define ABSL_INTERNAL_HAVE_SEM_WAITER 1
0037
0038 class SemWaiter : public WaiterCrtp<SemWaiter> {
0039 public:
0040 SemWaiter();
0041
0042 bool Wait(KernelTimeout t);
0043 void Post();
0044 void Poke();
0045
0046 static constexpr char kName[] = "SemWaiter";
0047
0048 private:
0049 int TimedWait(KernelTimeout t);
0050
0051 sem_t sem_;
0052
0053
0054
0055
0056 std::atomic<int> wakeups_;
0057 };
0058
0059 }
0060 ABSL_NAMESPACE_END
0061 }
0062
0063 #endif
0064
0065 #endif