1 /* 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_NATIVE_WIN_H_ 12 #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_NATIVE_WIN_H_ 13 14 #include <windows.h> 15 16 #include "webrtc/system_wrappers/include/condition_variable_wrapper.h" 17 18 namespace webrtc { 19 20 #if !defined CONDITION_VARIABLE_INIT 21 typedef struct RTL_CONDITION_VARIABLE_ { 22 void* Ptr; 23 } RTL_CONDITION_VARIABLE, *PRTL_CONDITION_VARIABLE; 24 25 typedef RTL_CONDITION_VARIABLE CONDITION_VARIABLE, *PCONDITION_VARIABLE; 26 #endif 27 28 typedef void (WINAPI* PInitializeConditionVariable)(PCONDITION_VARIABLE); 29 typedef BOOL (WINAPI* PSleepConditionVariableCS)(PCONDITION_VARIABLE, 30 PCRITICAL_SECTION, DWORD); 31 typedef void (WINAPI* PWakeConditionVariable)(PCONDITION_VARIABLE); 32 typedef void (WINAPI* PWakeAllConditionVariable)(PCONDITION_VARIABLE); 33 34 class ConditionVariableNativeWin : public ConditionVariableWrapper { 35 public: 36 static ConditionVariableWrapper* Create(); 37 virtual ~ConditionVariableNativeWin(); 38 39 void SleepCS(CriticalSectionWrapper& crit_sect); 40 bool SleepCS(CriticalSectionWrapper& crit_sect, unsigned long max_time_inMS); 41 void Wake(); 42 void WakeAll(); 43 44 private: 45 ConditionVariableNativeWin(); 46 47 bool Init(); 48 49 CONDITION_VARIABLE condition_variable_; 50 }; 51 52 } // namespace webrtc 53 54 #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CONDITION_VARIABLE_NATIVE_WIN_H_ 55