File indexing completed on 2025-01-18 09:38:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_INTERPROCESS_NAMED_CONDITION_ANY_HPP
0012 #define BOOST_INTERPROCESS_NAMED_CONDITION_ANY_HPP
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017 #
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 # pragma once
0020 #endif
0021
0022 #include <boost/interprocess/detail/config_begin.hpp>
0023 #include <boost/interprocess/detail/workaround.hpp>
0024
0025 #include <boost/interprocess/sync/cv_status.hpp>
0026 #include <boost/interprocess/creation_tags.hpp>
0027 #include <boost/interprocess/exceptions.hpp>
0028 #include <boost/interprocess/detail/interprocess_tester.hpp>
0029 #include <boost/interprocess/permissions.hpp>
0030 #include <boost/interprocess/sync/detail/locks.hpp>
0031 #if !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && defined (BOOST_INTERPROCESS_WINDOWS)
0032 #include <boost/interprocess/sync/windows/named_condition_any.hpp>
0033 #define BOOST_INTERPROCESS_NAMED_CONDITION_ANY_USE_WINAPI
0034 #else
0035 #include <boost/interprocess/sync/shm/named_condition_any.hpp>
0036 #endif
0037
0038
0039
0040
0041 namespace boost {
0042 namespace interprocess {
0043
0044 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0045 namespace ipcdetail{ class interprocess_tester; }
0046 #endif
0047
0048
0049
0050
0051 class named_condition_any
0052 {
0053 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0054
0055 named_condition_any();
0056 named_condition_any(const named_condition_any &);
0057 named_condition_any &operator=(const named_condition_any &);
0058 #endif
0059
0060 public:
0061
0062
0063 named_condition_any(create_only_t, const char *name, const permissions &perm = permissions())
0064 : m_cond(create_only_t(), name, perm)
0065 {}
0066
0067
0068
0069
0070
0071
0072
0073 named_condition_any(open_or_create_t, const char *name, const permissions &perm = permissions())
0074 : m_cond(open_or_create_t(), name, perm)
0075 {}
0076
0077
0078
0079
0080 named_condition_any(open_only_t, const char *name)
0081 : m_cond(open_only_t(), name)
0082 {}
0083
0084 #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0085
0086
0087
0088
0089
0090
0091 named_condition_any(create_only_t, const wchar_t *name, const permissions &perm = permissions())
0092 : m_cond(create_only_t(), name, perm)
0093 {}
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104 named_condition_any(open_or_create_t, const wchar_t *name, const permissions &perm = permissions())
0105 : m_cond(open_or_create_t(), name, perm)
0106 {}
0107
0108
0109
0110
0111
0112
0113
0114 named_condition_any(open_only_t, const wchar_t *name)
0115 : m_cond(open_only_t(), name)
0116 {}
0117
0118 #endif
0119
0120
0121
0122
0123
0124
0125
0126 ~named_condition_any()
0127 {}
0128
0129
0130
0131 void notify_one()
0132 { m_cond.notify_one(); }
0133
0134
0135
0136 void notify_all()
0137 { m_cond.notify_all(); }
0138
0139
0140
0141
0142 template <typename L>
0143 void wait(L& lock)
0144 { return m_cond.wait(lock); }
0145
0146
0147
0148 template <typename L, typename Pr>
0149 void wait(L& lock, Pr pred)
0150 { return m_cond.wait(lock, pred); }
0151
0152
0153
0154
0155
0156
0157 template <typename L, typename TimePoint>
0158 bool timed_wait(L& lock, const TimePoint &abs_time)
0159 { return m_cond.timed_wait(lock, abs_time); }
0160
0161
0162
0163
0164 template <typename L, typename TimePoint, typename Pr>
0165 bool timed_wait(L& lock, const TimePoint &abs_time, Pr pred)
0166 { return m_cond.timed_wait(lock, abs_time, pred); }
0167
0168
0169
0170 template <typename L, class TimePoint>
0171 cv_status wait_until(L& lock, const TimePoint &abs_time)
0172 { return this->timed_wait(lock, abs_time) ? cv_status::no_timeout : cv_status::timeout; }
0173
0174
0175
0176 template <typename L, class TimePoint, typename Pr>
0177 bool wait_until(L& lock, const TimePoint &abs_time, Pr pred)
0178 { return this->timed_wait(lock, abs_time, pred); }
0179
0180
0181
0182 template <typename L, class Duration>
0183 cv_status wait_for(L& lock, const Duration &dur)
0184 { return this->wait_until(lock, ipcdetail::duration_to_ustime(dur)); }
0185
0186
0187
0188 template <typename L, class Duration, typename Pr>
0189 bool wait_for(L& lock, const Duration &dur, Pr pred)
0190 { return this->wait_until(lock, ipcdetail::duration_to_ustime(dur), pred); }
0191
0192
0193
0194 static bool remove(const char *name)
0195 { return condition_any_type::remove(name); }
0196
0197 #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0198
0199
0200
0201
0202
0203
0204 static bool remove(const wchar_t *name)
0205 { return condition_any_type::remove(name); }
0206
0207 #endif
0208
0209 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0210 private:
0211 #if defined(BOOST_INTERPROCESS_NAMED_CONDITION_ANY_USE_WINAPI)
0212 typedef ipcdetail::winapi_named_condition_any condition_any_type;
0213 #else
0214 typedef ipcdetail::shm_named_condition_any condition_any_type;
0215 #endif
0216 condition_any_type m_cond;
0217
0218 friend class ipcdetail::interprocess_tester;
0219 void dont_close_on_destruction()
0220 { ipcdetail::interprocess_tester::dont_close_on_destruction(m_cond); }
0221 #endif
0222 };
0223
0224 }
0225 }
0226
0227 #include <boost/interprocess/detail/config_end.hpp>
0228
0229 #endif