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