]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | /* |
2 | * Copyright 2010 Vicente J. Botet Escriba | |
3 | * Copyright 2015 Andrey Semashev | |
4 | * | |
5 | * Distributed under the Boost Software License, Version 1.0. | |
6 | * See http://www.boost.org/LICENSE_1_0.txt | |
7 | */ | |
7c673cae | 8 | |
b32b8144 FG |
9 | #ifndef BOOST_WINAPI_CONDITION_VARIABLE_HPP_INCLUDED_ |
10 | #define BOOST_WINAPI_CONDITION_VARIABLE_HPP_INCLUDED_ | |
7c673cae | 11 | |
b32b8144 | 12 | #include <boost/winapi/config.hpp> |
7c673cae FG |
13 | |
14 | #ifdef BOOST_HAS_PRAGMA_ONCE | |
15 | #pragma once | |
16 | #endif | |
17 | ||
18 | #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 | |
19 | ||
b32b8144 | 20 | #include <boost/winapi/basic_types.hpp> |
20effc67 | 21 | #include <boost/winapi/detail/header.hpp> |
7c673cae FG |
22 | |
23 | #if !defined( BOOST_USE_WINDOWS_H ) | |
24 | extern "C" { | |
25 | struct _RTL_CONDITION_VARIABLE; | |
26 | struct _RTL_CRITICAL_SECTION; | |
27 | struct _RTL_SRWLOCK; | |
28 | ||
20effc67 | 29 | BOOST_WINAPI_IMPORT boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC |
7c673cae FG |
30 | InitializeConditionVariable(::_RTL_CONDITION_VARIABLE* ConditionVariable); |
31 | ||
20effc67 | 32 | BOOST_WINAPI_IMPORT boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC |
7c673cae FG |
33 | WakeConditionVariable(::_RTL_CONDITION_VARIABLE* ConditionVariable); |
34 | ||
20effc67 | 35 | BOOST_WINAPI_IMPORT boost::winapi::VOID_ BOOST_WINAPI_WINAPI_CC |
7c673cae FG |
36 | WakeAllConditionVariable(::_RTL_CONDITION_VARIABLE* ConditionVariable); |
37 | ||
20effc67 | 38 | BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC |
7c673cae FG |
39 | SleepConditionVariableCS( |
40 | ::_RTL_CONDITION_VARIABLE* ConditionVariable, | |
41 | ::_RTL_CRITICAL_SECTION* CriticalSection, | |
b32b8144 | 42 | boost::winapi::DWORD_ dwMilliseconds); |
7c673cae | 43 | |
20effc67 | 44 | BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC |
7c673cae FG |
45 | SleepConditionVariableSRW( |
46 | ::_RTL_CONDITION_VARIABLE* ConditionVariable, | |
47 | ::_RTL_SRWLOCK* SRWLock, | |
b32b8144 FG |
48 | boost::winapi::DWORD_ dwMilliseconds, |
49 | boost::winapi::ULONG_ Flags); | |
7c673cae FG |
50 | } |
51 | #endif | |
52 | ||
53 | namespace boost { | |
7c673cae FG |
54 | namespace winapi { |
55 | ||
b32b8144 | 56 | typedef struct BOOST_MAY_ALIAS _RTL_CONDITION_VARIABLE { |
7c673cae FG |
57 | PVOID_ Ptr; |
58 | } CONDITION_VARIABLE_, *PCONDITION_VARIABLE_; | |
59 | ||
60 | #if defined( BOOST_USE_WINDOWS_H ) | |
b32b8144 | 61 | #define BOOST_WINAPI_CONDITION_VARIABLE_INIT CONDITION_VARIABLE_INIT |
7c673cae | 62 | #else |
b32b8144 | 63 | #define BOOST_WINAPI_CONDITION_VARIABLE_INIT {0} |
7c673cae FG |
64 | #endif |
65 | ||
66 | struct _RTL_CRITICAL_SECTION; | |
67 | struct _RTL_SRWLOCK; | |
68 | ||
69 | BOOST_FORCEINLINE VOID_ InitializeConditionVariable(PCONDITION_VARIABLE_ ConditionVariable) | |
70 | { | |
71 | ::InitializeConditionVariable(reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable)); | |
72 | } | |
73 | ||
74 | BOOST_FORCEINLINE VOID_ WakeConditionVariable(PCONDITION_VARIABLE_ ConditionVariable) | |
75 | { | |
76 | ::WakeConditionVariable(reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable)); | |
77 | } | |
78 | ||
79 | BOOST_FORCEINLINE VOID_ WakeAllConditionVariable(PCONDITION_VARIABLE_ ConditionVariable) | |
80 | { | |
81 | ::WakeAllConditionVariable(reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable)); | |
82 | } | |
83 | ||
84 | BOOST_FORCEINLINE BOOL_ SleepConditionVariableCS( | |
85 | PCONDITION_VARIABLE_ ConditionVariable, | |
86 | _RTL_CRITICAL_SECTION* CriticalSection, | |
87 | DWORD_ dwMilliseconds) | |
88 | { | |
89 | return ::SleepConditionVariableCS( | |
90 | reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable), | |
91 | reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(CriticalSection), | |
92 | dwMilliseconds); | |
93 | } | |
94 | ||
95 | BOOST_FORCEINLINE BOOL_ SleepConditionVariableSRW( | |
96 | PCONDITION_VARIABLE_ ConditionVariable, | |
97 | _RTL_SRWLOCK* SRWLock, | |
98 | DWORD_ dwMilliseconds, | |
99 | ULONG_ Flags) | |
100 | { | |
101 | return ::SleepConditionVariableSRW( | |
102 | reinterpret_cast< ::_RTL_CONDITION_VARIABLE* >(ConditionVariable), | |
103 | reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock), | |
104 | dwMilliseconds, | |
105 | Flags); | |
106 | } | |
107 | ||
108 | #if defined( BOOST_USE_WINDOWS_H ) | |
92f5a8d4 | 109 | BOOST_CONSTEXPR_OR_CONST ULONG_ CONDITION_VARIABLE_LOCKMODE_SHARED_ = CONDITION_VARIABLE_LOCKMODE_SHARED; |
7c673cae | 110 | #else // defined( BOOST_USE_WINDOWS_H ) |
92f5a8d4 | 111 | BOOST_CONSTEXPR_OR_CONST ULONG_ CONDITION_VARIABLE_LOCKMODE_SHARED_ = 0x00000001; |
7c673cae FG |
112 | #endif // defined( BOOST_USE_WINDOWS_H ) |
113 | ||
92f5a8d4 | 114 | BOOST_CONSTEXPR_OR_CONST ULONG_ condition_variable_lockmode_shared = CONDITION_VARIABLE_LOCKMODE_SHARED_; |
7c673cae | 115 | |
7c673cae FG |
116 | } |
117 | } | |
118 | ||
20effc67 TL |
119 | #include <boost/winapi/detail/footer.hpp> |
120 | ||
7c673cae FG |
121 | #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 |
122 | ||
b32b8144 | 123 | #endif // BOOST_WINAPI_CONDITION_VARIABLE_HPP_INCLUDED_ |