Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-24 09:40:05

0001 // Copyright 2023 The Abseil Authors.
0002 //
0003 // Licensed under the Apache License, Version 2.0 (the "License");
0004 // you may not use this file except in compliance with the License.
0005 // You may obtain a copy of the License at
0006 //
0007 //      https://www.apache.org/licenses/LICENSE-2.0
0008 //
0009 // Unless required by applicable law or agreed to in writing, software
0010 // distributed under the License is distributed on an "AS IS" BASIS,
0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0012 // See the License for the specific language governing permissions and
0013 // limitations under the License.
0014 //
0015 
0016 #ifndef ABSL_SYNCHRONIZATION_INTERNAL_PTHREAD_WAITER_H_
0017 #define ABSL_SYNCHRONIZATION_INTERNAL_PTHREAD_WAITER_H_
0018 
0019 #if !defined(_WIN32) && !defined(__MINGW32__)
0020 #include <pthread.h>
0021 
0022 #include "absl/base/config.h"
0023 #include "absl/synchronization/internal/kernel_timeout.h"
0024 #include "absl/synchronization/internal/waiter_base.h"
0025 
0026 namespace absl {
0027 ABSL_NAMESPACE_BEGIN
0028 namespace synchronization_internal {
0029 
0030 #define ABSL_INTERNAL_HAVE_PTHREAD_WAITER 1
0031 
0032 class PthreadWaiter : public WaiterCrtp<PthreadWaiter> {
0033  public:
0034   PthreadWaiter();
0035 
0036   bool Wait(KernelTimeout t);
0037   void Post();
0038   void Poke();
0039 
0040   static constexpr char kName[] = "PthreadWaiter";
0041 
0042  private:
0043   int TimedWait(KernelTimeout t);
0044 
0045   // REQUIRES: mu_ must be held.
0046   void InternalCondVarPoke();
0047 
0048   pthread_mutex_t mu_;
0049   pthread_cond_t cv_;
0050   int waiter_count_;
0051   int wakeup_count_;  // Unclaimed wakeups.
0052 };
0053 
0054 }  // namespace synchronization_internal
0055 ABSL_NAMESPACE_END
0056 }  // namespace absl
0057 
0058 #endif  // !defined(_WIN32) && !defined(__MINGW32__)
0059 
0060 #endif  // ABSL_SYNCHRONIZATION_INTERNAL_PTHREAD_WAITER_H_