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