Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:31:56

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_WIN32_WAITER_H_
0017 #define ABSL_SYNCHRONIZATION_INTERNAL_WIN32_WAITER_H_
0018 
0019 #ifdef _WIN32
0020 #include <sdkddkver.h>
0021 #endif
0022 
0023 #if defined(_WIN32) && !defined(__MINGW32__) && \
0024     _WIN32_WINNT >= _WIN32_WINNT_VISTA
0025 
0026 #include "absl/base/config.h"
0027 #include "absl/synchronization/internal/kernel_timeout.h"
0028 #include "absl/synchronization/internal/waiter_base.h"
0029 
0030 namespace absl {
0031 ABSL_NAMESPACE_BEGIN
0032 namespace synchronization_internal {
0033 
0034 #define ABSL_INTERNAL_HAVE_WIN32_WAITER 1
0035 
0036 class Win32Waiter : public WaiterCrtp<Win32Waiter> {
0037  public:
0038   Win32Waiter();
0039 
0040   bool Wait(KernelTimeout t);
0041   void Post();
0042   void Poke();
0043 
0044   static constexpr char kName[] = "Win32Waiter";
0045 
0046  private:
0047   // WinHelper - Used to define utilities for accessing the lock and
0048   // condition variable storage once the types are complete.
0049   class WinHelper;
0050 
0051   // REQUIRES: WinHelper::GetLock(this) must be held.
0052   void InternalCondVarPoke();
0053 
0054   // We can't include Windows.h in our headers, so we use aligned character
0055   // buffers to define the storage of SRWLOCK and CONDITION_VARIABLE.
0056   // SRW locks and condition variables do not need to be explicitly destroyed.
0057   // https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-initializesrwlock
0058   // https://stackoverflow.com/questions/28975958/why-does-windows-have-no-deleteconditionvariable-function-to-go-together-with
0059   alignas(void*) unsigned char mu_storage_[sizeof(void*)];
0060   alignas(void*) unsigned char cv_storage_[sizeof(void*)];
0061   int waiter_count_;
0062   int wakeup_count_;
0063 };
0064 
0065 }  // namespace synchronization_internal
0066 ABSL_NAMESPACE_END
0067 }  // namespace absl
0068 
0069 #endif  // defined(_WIN32) && !defined(__MINGW32__) &&
0070         // _WIN32_WINNT >= _WIN32_WINNT_VISTA
0071 
0072 #endif  // ABSL_SYNCHRONIZATION_INTERNAL_WIN32_WAITER_H_